1

I am using ftp apache's commomns net version 3.1 .

The ftp connection gets in hung state while doing listing operation INTERMITTENTLY .

The reason i feel so seems to be ftp client is kept waiting indefnitely for server response for FTP command PASV while trying to open data connection for listing operation.

How do i need to set read timeout on control connection to avoid this situation.

I have set readtimeout on data connection using setDataTimeout().

For more refer : http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html#setDataTimeout(int)

1)Does setting setsoTimeout() after doing ftp connect() operation helps avoiding this situation on control connection?

For more refer : http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/SocketClient.html#setSoTimeout(int)

2)If so,what is the optimum timeout value i need to set for setsotimeout() ?

Please find stack trace below:

at java.net.SocketInputStream.socketRead0(Native Method)                 
at java.net.SocketInputStream.read(SocketInputStream.java:140)           
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:464)  
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:506)   
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:234)                 
at java.io.InputStreamReader.read(InputStreamReader.java:188)            
at java.io.BufferedReader.fill(BufferedReader.java:147)                  
at java.io.BufferedReader.read(BufferedReader.java:168)                  
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58 
)                                                                        
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:310)               
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)               
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:479)              
at org.apache.commons.net.ftp.FTPClient.openDataConnection(FTPClient.java:7 
69)
at org.apache.commons.net.ftp.FTPClient.openDataConnection(FTPClient.java:6 
57) 
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java: 
3097) 
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java: 
3072)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java: 
2972

Any help on this will be appreciated:)

Thanks.

0 Answers0