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

9

74

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 https://bugs.java.com/bugdatabase/view_bug?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."

Thibodeau answered 9/8, 2011 at 2:2 Comment(3)
Very annoying indeed, it also affects the Ant FTP task: java.net.SocketException: Permission denied: recv failed at org.apache.tools.ant.taskdefs.optional.net.FTP$FTPDirectoryScanner.forceRemoteSensitivityCheck(FTP.java:695)Ferule
workaround: #10474018Bub
#17762259Integrated
R
14

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

Ruination answered 1/11, 2012 at 15:41 Comment(2)
Does this hotfix also solve the problem for Windows Vista? It is not listed in the prerequisites.Aparicio
We did not test this on VistaRuination
H
88

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.

Handout answered 5/10, 2011 at 7:16 Comment(4)
And here I was thinking that there was something wrong with my code. Stupid Win7 firewall + Java interactions. +1.Archipenko
Confirmed that this fixed the issue with Java 1.7.0_09 and Windows Vista Home Premium (with SP2).Wilcher
worked for me, and way more quick than that hell of a hotfix from MSIanthe
netsh advfirewall set global StatefulFTP disable worked for me :)Anticatalyst
D
15

Another workaround is to start the JVM with:

-Djava.net.preferIPv4Stack=true
Delora answered 25/11, 2011 at 2:5 Comment(1)
I had this problem in an applet, so I'm using: System.setProperty("java.net.preferIPv4Stack", "true"); Every browser except for Firefox (16.0.2) works then.Rhyme
T
14

I've submitted a bug report to Oracle, see 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.

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

Thibodeau answered 24/8, 2011 at 4:46 Comment(1)
workaround: #10474018Bub
R
14

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

Ruination answered 1/11, 2012 at 15:41 Comment(2)
Does this hotfix also solve the problem for Windows Vista? It is not listed in the prerequisites.Aparicio
We did not test this on VistaRuination
C
5

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 https://bugs.java.com/bugdatabase/view_bug?bug_id=7077696 for more details and workarounds.

Connotative answered 14/11, 2011 at 10:11 Comment(0)
G
2

Blogged about the issue here: 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.

Graphitize answered 12/9, 2011 at 14:52 Comment(2)
Thanks. By the way, active transfers (i.e. PORT command) are also affected.Thibodeau
Thanks for the heads up HansA, i'll change the blogpost.Graphitize
T
2

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.

Tripe answered 10/12, 2012 at 7:47 Comment(0)
S
1

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

Stammel answered 2/9, 2011 at 20:9 Comment(0)
P
0

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:

C: \ Users \ pc01> netsh advfirewall set global StatefulFTP disable
Perseid answered 16/3, 2017 at 14:55 Comment(1)
Stack Overflow requires that all posts be in English. I edited your post to comply with this rule. There are language specific Stack Overflow communities which allow non-English: Spanish, Japanese, Russian, Portuguese.Marcelo

© 2022 - 2024 — McMap. All rights reserved.