k8s节点应用服务ftp accept timed out
问题描述:应用部署在k8s容器中,有ftp下载功能时报“accept timed out”如下所示2022-04-14 20:19:10.392 [pool-6-thread-3] INFO[10.244.114.7]*****.ftp.FTPClientAdapter - [,] - Connect to server 172.16.0.44, reply code is 2202022-04-
·
问题描述:应用部署在k8s容器中,有ftp下载功能时报“accept timed out”
如下所示
2022-04-14 20:19:10.392 [pool-6-thread-3] INFO [10.244.114.7] *****.ftp.FTPClientAdapter - [,] - Connect to server 172.16.0.44, reply code is 220
2022-04-14 20:19:10.394 [pool-6-thread-3] INFO [10.244.114.7] *****.FTPClientAdapter - [,] - Login to server 172.16.0.44, status true, reply code is 230
2022-04-14 20:19:10.396 [pool-6-thread-3] INFO [10.244.114.7] ***** .FtpClient - [,] - Change ftp to working dir /hujin
2022-04-14 20:21:10.481 [pool-6-thread-3] ERROR [10.244.114.7] *****.EmailMessageServiceImpl - [,] - send email error
java.net.SocketTimeoutException: Accept timed out
at java.net.PlainSocketImpl.socketAccept(Native Method) ~[?:1.8.0_191]
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409) ~[?:1.8.0_191]
at java.net.ServerSocket.implAccept(ServerSocket.java:545) ~[?:1.8.0_191]
at java.net.ServerSocket.accept(ServerSocket.java:513) ~[?:1.8.0_191]
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:806) ~[commons-net-3.8.0.jar!/:3.8.0]
at org.apache.commons.net.ftp.FTPClient._retrieveFile(FTPClient.java:971) ~[commons-net-3.8.0.jar!/:3.8.0]
at org.apache.commons.net.ftp.FTPClient.retrieveFile(FTPClient.java:3308) ~[commons-net-3.8.0.jar!/:3.8.0]
从上面可以看出ftp登录以及切换目录都成功了,但是调用ftp的retrieveFile方法就下载不下来文件。
测试环境能正常下载,而容器化部署报错。
解决方案:其实这个问题很容易解决
原先ftp client创建是被动模式导致在容器化部署的环境ftp下载文件失败
ftpClient.enterLocalPassiveMode()
上述代码即可解决该问题。
有兴趣可以了解下ftp主被动模式
更多推荐
已为社区贡献1条内容
所有评论(0)