ftp inbound-channel-adapter在同步时抛出异常

时间:2015-08-06 10:19:22

标签: spring ftp spring-integration apache-commons

我有一个写在SI上的模块,它运行了很长时间没有任何打嗝。最近我在日志中看到了以下错误

org.springframework.integration.MessagingException: Problem occurred while synchronizing remote to local directory
at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:156)
at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.receive(AbstractInboundFileSynchronizingMessageSource.java:146)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:111)
at org.springframework.integration.endpoint.AbstractTransactionSynchronizingPollingEndpoint.doPoll(AbstractTransactionSynchronizingPollingEndpoint.java:67)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:144)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:236)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:231)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketTimeoutException: Accept timed out
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.PlainSocketImpl.accept(Unknown Source)
    at java.net.ServerSocket.implAccept(Unknown Source)
    at java.net.ServerSocket.accept(Unknown Source)
    at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:693)
    at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2990)
    at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2965)
    at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2623)
    at org.springframework.integration.ftp.session.FtpSession.list(FtpSession.java:62)
    at org.springframework.integration.ftp.session.FtpSession.list(FtpSession.java:38)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:145)
    ... 20 more

重新启动组件后,错误消失了,但我仍然很想知道原因并修复它。

从这个link我可以说有一段时间可能存在一些网络问题,之后我在同步时开始收到此错误但是一旦网络连接恢复就应该停止异常(如果有的话)网络问题一直存在。)

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

尝试使用被动ftp(谷歌搜索主动和被动ftp之间的区别)。

主动FTP在防火墙等方面非常困难,因为服务器会打开一个回到客户端的连接。这是上面的堆栈跟踪中的超时。也许有些港口是开放的,有些则不是。

使用被动模式,客户端启动数据连接。

将连接工厂的clientMode属性设置为

FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE

2)。