-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linux环境:java.net.SocketException: Broken pipe (Write failed) #2
Comments
抱歉现在才看到,能否提供更详细的信息,比如是否在多线程环境下,或者文件是否过大,ftp服务器的配置之类的。 |
not help |
谢谢,我重新尝试下;我配置了这个参数,没看你底层实现 @jayknoxqu 这是我的配置 ftpClient.setControlKeepAliveTimeout(ftpClientConfig.getControlKeepAliveTimeout()); 应该是服务器端口被关闭了,目前没有其他办法。 |
你不会是sftp吧? |
还真不是,就是普通的FTP。我不使用池化的方法还行,但是一起用池化的;就 |
"我不使用池化的方法还行,但是一起用池化的",能具体描述下么我这边没办法复现出来,是像测试类里那样使用么? |
多线程一次性发送100张图片到FTP服务器,使用FTPClientPool就会出现了;如果是使用 new FTPClient不会出现这种情况 |
FtpClientPool是标记为不弃用的;
方法创建连接池 |
/**
JobHandler(xxxJob调度) 在Linux环境下定时周期1分钟,就可以看到后台有该异常 |
这个没有问题,我看了common-pool的实现是一致的。 |
windows环境下,长期观察下。就可以看到这个 |
public FtpClientTemplate(FtpClientFactory ftpClientFactory) { 加了这个之后,看到异常堆栈。校验到Connection已经异常了 |
six six six |
写的太假了,自己写都比你那个强 |
写的挺好的,还需要考虑的点还有很多而已。这个目前还是一个待完善版本,类似于 |
非常感谢你提出了这么多问题, |
应该的,互相学习。应该是保活机制不完善,连接池没有对于池中连接进行有效性处理以及外部服务,网络抖动都可能导致这些失效。 |
|
Redis 的客户端 Jedis也是通过GenericObjectPool来实现的
可看下它具体是怎么来实现的, |
@jayknoxqu 就你玩的花哨 |
在检测到对象失效的时候,重新登录连接上ftp服务器,在放回对象池 |
试下这几个参数,每次获取一个连接,返还一个连接都测试 一下是否是可用的状态 ,如果不是会自动删除并重建,然后获取下一个 |
有更强的版本吗?从池中获取的client可能是断开的。导致程序异常。 |
@fortunelee 楼主写的这个挺好的,思想不错,pool2这个思想的确值得学习。但是FTP这个协议的确很复杂,数据口和控制口是两个socket,而且还要根据具体的FTP server端去配置client。兄台你这个头像挺骚气啊 |
Dear email is ok!
|
java.net.SocketException: Broken pipe (Write failed)
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.apache.commons.net.ftp.FTP.__send(FTP.java:545)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:519)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:648)
at org.apache.commons.net.ftp.FTP.cwd(FTP.java:868)
at org.apache.commons.net.ftp.FTPClient.changeWorkingDirectory(FTPClient.java:1167)
at com.yinghuo.contract.biz.core.util.ftp.FtpClientTemplate.uploadFile(FtpClientTemplate.java:56)
在linux 环境下容易出现session超时。需要保证keepAlive
The text was updated successfully, but these errors were encountered: