FtpClient上传文件异常:java.net.SocketException: Connection reset
Posted on 2017-12-26 16:14 Simon1020 阅读(5263) 评论(0) 编辑 收藏 举报FtpClient上传文件异常:java.net.SocketException: Connection reset
这问题折磨我快一天了,下午这会儿终于解决了,问题不在程序错误,原因还是出在上传图片的客户端:
贴上异常代码块:
16:38:20.117 INFO com.code.platform.common.utils.FtpClient.ftpLogin@71 - 成功登陆FTP服务器 16:38:20.123 ERROR com.code.platform.common.utils.FtpClient.uploadFile@166 - Connection reset java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:196) ~[?:1.7.0_79] at java.net.SocketInputStream.read(SocketInputStream.java:122) ~[?:1.7.0_79] at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) ~[?:1.7.0_79] at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) ~[?:1.7.0_79] at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) ~[?:1.7.0_79] at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[?:1.7.0_79]
解决办法:
禁用有状态 FTP 筛选,以使防火墙不会阻止任何 FTP 通信
dos窗口下执行:netsh advfirewall set global StatefulFTP disable
附参考网址:https://technet.microsoft.com/zh-cn/library/dd421710%28v=ws.10%29.aspx