You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "linux.power" <li...@laposte.net> on 2006/06/20 15:28:22 UTC

[net] Problem with timeout and threads ?!

Hi everybody !

I have a daemon program that fetches files by ftp every 30
minutes. I use commons net in order to fetch theses ftp files.

It works well during a good time but after a few days, it
doesn't fetch anything.
I realized that one thread was blocked, so no more files
was fetched :

Stack trace:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:474)
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:339)
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:466)
java.io.BufferedInputStream.read1(BufferedInputStream.java:254)
java.io.BufferedInputStream.read(BufferedInputStream.java:313)
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
java.io.InputStreamReader.read(InputStreamReader.java:167)
java.io.BufferedReader.fill(BufferedReader.java:136)
java.io.BufferedReader.readLine(BufferedReader.java:299)
java.io.BufferedReader.readLine(BufferedReader.java:362)
org.apache.commons.net.ftp.FTP.__getReply(FTP.java:264)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:460)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:520)
org.apache.commons.net.ftp.FTPClient.retrieveFileStream(FTPClient.java:1342)

For information, I set a time out by using "setDataTimeout"
on FTPClient.

I don't know what happen ! Can you help me ?
Is there a way with "setReaderThread(false)" ?!

Thanks in advance :)

Accédez au courrier électronique de La Poste : www.laposte.net
3615 LAPOSTENET (0,34 €/mn)



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [net] Problem with timeout and threads ?!

Posted by Tux <li...@laposte.net>.
I looked for various explanations, and I found the same problem with an 
other stack :

Stack trace:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:474)
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:339)
org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:466)
java.io.BufferedInputStream.read1(BufferedInputStream.java:254)
java.io.BufferedInputStream.read(BufferedInputStream.java:313)
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
java.io.InputStreamReader.read(InputStreamReader.java:167)
java.io.BufferedReader.fill(BufferedReader.java:136)
java.io.BufferedReader.readLine(BufferedReader.java:299)
java.io.BufferedReader.readLine(BufferedReader.java:362)
org.apache.commons.net.ftp.FTP.__getReply(FTP.java:264)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:460)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:569)
org.apache.commons.net.ftp.FTP.pasv(FTP.java:869)
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:508)
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2390)
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2364)
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2090)

We can see that the problem occurred with the "pasv" method, that is to 
say before the "createSocket" call in FTPClient (in passive mode) :

else
{ // We must be in PASSIVE_LOCAL_DATA_CONNECTION_MODE

if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
return null;

__parsePassiveModeReply((String)_replyLines.elementAt(0));

socket = _socketFactory_.createSocket(__passiveHost, __passivePort);
if ((__restartOffset > 0) && !restart(__restartOffset))
{
socket.close();
return null;
}

if (!FTPReply.isPositivePreliminary(sendCommand(command, arg)))
{
socket.close();
return null;
}
}

Is it normal that there is no time out on this method ?
Because I see that time out is set at the end of the method :

if (__dataTimeout >= 0)
socket.setSoTimeout(__dataTimeout);

return socket;


Am I Wrong ?



linux.power a écrit :
> Hi everybody !
>
> I have a daemon program that fetches files by ftp every 30
> minutes. I use commons net in order to fetch theses ftp files.
>
> It works well during a good time but after a few days, it
> doesn't fetch anything.
> I realized that one thread was blocked, so no more files
> was fetched :
>
> Stack trace:
> java.lang.Object.wait(Native Method)
> java.lang.Object.wait(Object.java:474)
> org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:339)
> org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:466)
> java.io.BufferedInputStream.read1(BufferedInputStream.java:254)
> java.io.BufferedInputStream.read(BufferedInputStream.java:313)
> sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
> sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
> sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
> java.io.InputStreamReader.read(InputStreamReader.java:167)
> java.io.BufferedReader.fill(BufferedReader.java:136)
> java.io.BufferedReader.readLine(BufferedReader.java:299)
> java.io.BufferedReader.readLine(BufferedReader.java:362)
> org.apache.commons.net.ftp.FTP.__getReply(FTP.java:264)
> org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:460)
> org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
> org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:520)
> org.apache.commons.net.ftp.FTPClient.retrieveFileStream(FTPClient.java:1342)
>
> For information, I set a time out by using "setDataTimeout"
> on FTPClient.
>
> I don't know what happen ! Can you help me ?
> Is there a way with "setReaderThread(false)" ?!
>
> Thanks in advance :)
>
> Accédez au courrier électronique de La Poste : www.laposte.net
> 3615 LAPOSTENET (0,34 €/mn)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org