如果防火墙打开,Java 7 会阻止 Windows Vista 和 7 上的 FTP 传输。有任何想法吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6990663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:39:24  来源:igfitidea点击:

Java 7 prevents FTP transfers on Windows Vista and 7 if firewall is on. Any ideas?

windowsftpjava-7windows-firewallwfp

提问by HansA

Java 7 prevents FTP transfers on Windows Vista and 7.

Java 7 阻止 Windows Vista 和 7 上的 FTP 传输。

In FTP, before a file is transferred a PORT or a PASV command must be sent. As soon as one of the commands is sent the Windows Firewall closes the socket that sent it. This only happens if the firewall is on and an exception for java.exe is absent. I suspect this problem is related to Java 7 using the new Vista IP stack.

在 FTP 中,在传输文件之前,必须先发送 PORT 或 PASV 命令。一旦发送了其中一个命令,Windows 防火墙就会关闭发送它的套接字。这只发生在防火墙打开并且没有 java.exe 异常的情况下。我怀疑这个问题与使用新的 Vista IP 堆栈的 Java 7 有关。

Does anyone have any ideas how to fix or work around this problem? We're distributing a Java FTP library so we obviously can't add exceptions ourselves.

有没有人有任何想法如何解决或解决这个问题?我们正在分发一个 Java FTP 库,所以我们显然不能自己添加异常。

Exception:

例外:

java.net.SocketException: Permission denied: recv failed

JRE version info:

JRE 版本信息:

java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


FOLLOW-UP 1 (14 November 2011):Oracle has analysed the problem and have found that it seems to be a bug in Windows Firewall and/or the IPv6 stack. They managed to replicate the problem with a native C (i.e. non-Java) app, so this is strong evidence that the bug is not in Java. They have informed Microsoft, so the ball is in their court now. More details can be found at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696

跟进 1(2011 年 11 月 14 日):Oracle 已分析该问题并发现它似乎是 Windows 防火墙和/或 IPv6 堆栈中的错误。他们设法用本机 C(即非 Java)应用程序复制了该问题,因此这是该错误不在 Java 中的有力证据。他们已经通知了微软,所以现在球在他们的球场上。可以在http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696上找到更多详细信息

FOLLOW-UP 2 (27 July 2012):A (very helpful) contact at Oracle has told me that the issue has now been escalated at Microsoft. We're hoping to see some results soon.

跟进 2(2012 年 7 月 27 日):Oracle 的一位(非常有帮助的)联系人告诉我,该问题现已在 Microsoft 上报。我们希望很快看到一些结果。

FOLLOW-UP 3 (15 August 2012):Our contact at Oracle has told us that Microsoft has accepted the bug and is in the process of prioritizing it.

跟进 3(2012 年 8 月 15 日):我们在 Oracle 的联系人告诉我们,Microsoft 已接受该错误并正在对其进行优先处理。

FOLLOW-UP 4 (21 September 2012):Microsoft has produced a patch that is currently being tested by Oracle. No word on a release date.

后续行动 4(2012 年 9 月 21 日):Microsoft 制作了一个补丁,目前正在由 Oracle 进行测试。没有关于发布日期的消息。

FOLLOW-UP 5 (11 October 2012):Success at last! Microsoft has publicly released a hotfix. They imply that the fix will be included in a general software update in the future:

跟进 5(2012 年 10 月 11 日):终于成功了!微软已经公开发布了一个修补程序。它们暗示该修复将包含在未来的一般软件更新中:

"if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix."

“如果您没有受到此问题的严重影响,我们建议您等待包含此修补程序的下一个软件更新。”

采纳答案by lyaffe

We tested the Windows hotfix http://support.microsoft.com/kb/2754804and confirmed that it did resolve the problem.

我们测试了 Windows 修补程序http://support.microsoft.com/kb/2754804并确认它确实解决了问题。

回答by Chris

The problem is caused by the stateful FTP filter of the firewall. As a workaround you can disable it by executing netsh advfirewall set global StatefulFTP disablewith administrator rights.

该问题是由防火墙的有状态 FTP 过滤器引起的。作为解决方法,您可以通过netsh advfirewall set global StatefulFTP disable以管理员权限执行来禁用它。

回答by HansA

I've submitted a bug report to Oracle, see bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696

我已向 Oracle 提交了错误报告,请参阅bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696

They've marked the priority as low, which makes me think that they don't quite understand the magnitude of the problem, i.e. that FTP is broken on Java/Windows. I forgot to state that explicitly in the bug report. If anyone else feels like it should have a higher priority please add a comment to the Oracle bug report.

他们将优先级标记为低,这让我认为他们不太了解问题的严重性,即 FTP 在 Java/Windows 上被破坏。我忘了在错误报告中明确说明这一点。如果其他人认为它应该具有更高的优先级,请在 Oracle 错误报告中添加评论。

I just noticed that you can also 'vote' for the bug, so please give it a vote if you agree it's significant.

我刚刚注意到你也可以为这个错误“投票”,所以如果你同意它很重要,请给它投票。

回答by prunge

Another workaround is to start the JVM with:

另一种解决方法是使用以下命令启动 JVM:

-Djava.net.preferIPv4Stack=true

回答by Alan

This problem can be demonstrated without JDK7, it's the firewall in Windows 7 blocking the ftp protocol when the application is using IPv6-mapped IPv4 addresses. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696for more details and workarounds.

这个问题可以在没有 JDK7 的情况下得到证明,当应用程序使用 IPv6 映射的 IPv4 地址时,Windows 7 中的防火墙阻止了 ftp 协议。有关更多详细信息和解决方法,请参阅http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7077696

回答by Y.Huang

Actually TFTP under JDK7 on windows 7 also have the same problem, the MS hotfix does resolve FTP issue, but still not works for TFTP. Seems Oracle should report the same problem to MS and get another hotfix to resolve TFTP issue as well.

实际上windows 7上JDK7下的TFTP也有同样的问题,MS hotfix确实解决了FTP问题,但仍然不适用于TFTP。似乎 Oracle 应该向 MS 报告同样的问题,并获得另一个修补程序来解决 TFTP 问题。

回答by Tommie

Blogged about the issue here: http://podzemski.com/2011/09/12/java-7-prevents-ftp-transfers-on-windows-when-firewall-is-on/

在博客上讨论了这个问题:http: //podzemski.com/2011/09/12/java-7-prevents-ftp-transfers-on-windows-when-firewall-is-on/

Maybe it'll cause some additional awareness of the problem.

也许它会引起对问题的一些额外认识。

回答by Dave

The same bug was reported here with a test case: Java 7 Socket Exception Bugforum. Its an issue with Java 7

这里用一个测试用例报告了同样的错误: Java 7 Socket Exception Bug论坛。它是 Java 7 的一个问题

回答by Davis Gereda Hernandez

I had the same problem using IDE Eclipse Neon, JAVA 7 and Windows 7 Professional. Trying to upload a PDF file to an FTP server. I solved it by running the following command in CMD as administrator:

我在使用 IDE Eclipse Neon、JAVA 7 和 Windows 7 Professional 时遇到了同样的问题。尝试将 PDF 文件上传到 FTP 服务器。我通过在 CMD 中以管理员身份运行以下命令来解决它:

C: \ Users \ pc01> netsh advfirewall set global StatefulFTP disable