Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.1k views
in Java FTP by
Hi there,

I have a question on method login of FTPClient. Is this blocking call? Is it possible login() blocked forever.

The below is an except from thread dump of Java VM:
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:408)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:450)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
- locked <0xec4cb7c0> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
- locked <0xec4cb7c0> (a java.io.InputStreamReader)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.login(Unknown Source)

Thx

4 Answers

0 votes
by (51.6k points)
The client is waiting for the server to reply to a command. What sort of server are you connecting to? Have you tried connecting using an FTP application (e.g. ftp.exe or filezilla)?

You can set a timeout (FTPClient.setTimeout) so that it won't hang forever.

- Hans (EDT)
0 votes
by
Thanks for pointing timeout. This is I am looking for. Don't know the server too much, but ftp on Sun works fine.
0 votes
by
Forgot to ask doc reference on settimeout, such as when to use and what kind exception is it thrown out when timeout happens.

Also just saw a even worse case, see below traceback from thread dump:
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:408)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:450)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
- locked <0xeced8070> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
- locked <0xeced8070> (a java.io.InputStreamReader)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.validateConnection(Unknown
Source)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.<init>(Unknown Source)

Can timeout work for this case happened during construction?
I don't see default constructor for FTPClient has been defined.
0 votes
by (162k points)
To figure out why this is occuring you'll need to post the log file (see the Dev Guide).

Categories

...