Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4k views
in Java FTP by (300 points)
Hi,
I have a problem with active FTP mode. I sometimes get "java.net.SocketTimeoutException: Accept timed out" exceptions. I took a look at the code and noticed that the accept on the data socket is not called until FTPActiveDataSocket.getOutputStream() or FTPActiveDataSocket.getInputStream() is called.
Could this be the problem? If one is unlucky with context switches the server might have tried to connect before accept is called?
09:20:34 WARN [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] StdFtpExporter - Faild to transfer file.
java.net.SocketTimeoutException: Accept timed out
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
at java.net.ServerSocket.implAccept(ServerSocket.java:450)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at com.enterprisedt.net.ftp.FTPActiveDataSocket.acceptConnection(FTPActiveDataSocket.java:113)
at com.enterprisedt.net.ftp.FTPActiveDataSocket.getOutputStream(FTPActiveDataSocket.java:127)
at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1504)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1324)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1288)
at com.unifaun.ee.base.exporter.StdFtpExporter.process(StdFtpExporter.java:173)
at com.unifaun.ee.base.exporter.ExportProcessor.process(ExportProcessor.java:123)
at com.unifaun.af.container.plugin.taskprocessor.TaskProcessorPlugin.run(TaskProcessorPlugin.java:109)
at com.unifaun.af.container.PluginThreadHandlerImpl$ThreadRunnable.run(PluginThreadHandlerImpl.java:54)
at java.lang.Thread.run(Thread.java:595)


Client-side log (edt):
09:19:29 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - ---> PORT XX,XX,XX,XX,XXX,XXX
09:19:29 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - 200 Command okay.
09:19:29 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - ---> STOR 20070927_091927_HDSEVENT_3295_0_1.edi
09:19:29 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - 150 Opening data connection to XX.XX.XX.XX(XXXXX).
09:19:29 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - Transferred 867 bytes to remote host
09:19:32 DEBUG [EXPORTER-TFS-EVENT] [20070927_091927_HDSEVENT_3295_0_1] - 226 F?rs?ndelse ftp200709270919395p4029@il49 accepterad
09:19:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - ---> PORT XX,XX,XX,XX,XXX,XXX
09:19:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - 200 Command okay.
09:19:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - ---> STOR 20070927_091932_HDSEVENT_3296_0_1.edi
09:19:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - 150 Opening data connection to XX.XX.XX.XX(XXXXX).
09:20:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - Transferred 0 bytes to remote host
09:20:34 DEBUG [EXPORTER-TFS-EVENT] [20070927_091932_HDSEVENT_3296_0_1] - ---> QUIT


Sever side log (clock is out of synch with the client):
070927 09:19:39 [4029] (CMD) => PORT XX,XX,XX,XX,XXX,XXX
070927 09:19:39 [4029] (CMD) <= 200 Command okay.
070927 09:19:39 [4029] (CMD) => STOR 20070927_091927_HDSEVENT_3295_0_1.edi
070927 09:19:39 [4029] (CMD) => Genererat m

2 Answers

0 votes
by (162k points)
I guess what you are saying is possible, however since accept() is a blocking operation unless asynchronous I/O is being used, I don't think you can't really call it anywhere else without halting the entire thread.
0 votes
by (300 points)
The late accept is probably not the problem. I did some testing and came to the conclusion that ServerSocket will queue up connections from when it is created.

Categories

...