ftp4j揭示java.net.SocketException: Connection reset的解決


ftp4j提示java.net.SocketException: Connection reset的解決
系統的自動更新FTP服務器,其他計算機連接都沒有問題,包括xp、server2008、win7、win8,簡體和繁體。

今天發現一台簡體win7無法自動更新,提示錯誤如下:
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
        at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
        at sun.nio.cs.StreamDecoder.read(Unknown Source)
        at sun.nio.cs.StreamDecoder.read0(Unknown Source)
        at sun.nio.cs.StreamDecoder.read(Unknown Source)
        at java.io.InputStreamReader.read(Unknown Source)
        at it.sauronsoftware.ftp4j.NVTASCIIReader.readLine(NVTASCIIReader.java:1
05)
        at it.sauronsoftware.ftp4j.FTPCommunicationChannel.read(FTPCommunication
Channel.java:142)
        at it.sauronsoftware.ftp4j.FTPCommunicationChannel.readFTPReply(FTPCommu
nicationChannel.java:185)
        at it.sauronsoftware.ftp4j.FTPClient.openPassiveDataTransferChannel(FTPC
lient.java:3179)
        at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.j
ava:3113)
        at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2019)
        at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2193)
        at cn.stjauns.logan.updater.Updater.getRemotefiles(Updater.java:199)
        at cn.stjauns.logan.updater.Updater.doUpdate(Updater.java:58)
        at cn.stjauns.logan.updater.Starter.main(Starter.java:18)

關閉win7自帶防火牆,一切正常。

上百度查詢,無果。
上google查詢,答案見:http://stackoverflow.com/questions/10166337/ftp-error-while-downloading-uploading-with-ftp4j-library-in-java-application。

引用

Apparently there is a bug on the Windows 7 firewall related to using FTP on IPv6 that would explain your problem. See bug report here.

Any one of the following workarounds should suffice to fix it:

Run the following as an administrator in a Windows console:

netsh advfirewall set global StatefulFtp disable

Run the JVM with the option: -Djava.net.preferIPv4Stack=true



打開win7防火牆,以管理員身份運行cmd,運行如下命令:
netsh advfirewall set global StatefulFtp disable
問題解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM