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

HansA picture HansA · Aug 9, 2011 · Viewed 49.8k times · Source

Java 7 prevents FTP transfers on Windows Vista and 7.

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.

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.

Exception:

java.net.SocketException: Permission denied: recv failed

JRE version info:

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

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.

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.

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

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:

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

Answer

Chris picture Chris · Oct 5, 2011

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 disable with administrator rights.