commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Boevink" <peter.boev...@alfa-ariss.com>
Subject RE: [net]TelnetClient.getInputStream.write() causes SocketTimeOutException immediately
Date Tue, 27 Sep 2005 12:41:18 GMT
Too bad that i had to solve this problem by myself.
For all other people struggeling with the same problem, here is what I found:

When creating an instance of TelnetClient() be sure to disable the readerThread by calling:
TelnetClient.setReaderThread(false); //(before connecting)

Otherwise the ReaderThread will cause a SocketTimeOutException which is immediately thrown
at the next:
TelnetClient.getInputStream.write();

So in my opinion you should never use a ReaderThread in combination with:
TelnetClient.setSoTimeout(millis);


> -----Original Message-----
> From: Peter Boevink 
> Sent: Friday, September 23, 2005 9:17 AM
> To: Jakarta Commons Users List
> Subject: RE: [net]TelnetClient.getInputStream.write() causes
> SocketTimeOutException immediately
> 
> 
> Discovered that the next 'read' will throw a 
> SocketTimeoutException if the previous 'read' was more than 
> 'SoTimeOut' ago.
> 
> For some strange reason there seems to be thrown this 
> Exception in some 'background' process even if i'm not 
> reading anymore. The next time I want to read it looks like 
> the exception is passed through.
> 
> Does this have anything to do with the 'ReaderThread' of the 
> TelnetClient?
> 
> > -----Original Message-----
> > From: Peter Boevink 
> > Sent: Thursday, September 22, 2005 2:09 PM
> > To: commons-user@jakarta.apache.org
> > Subject: [net]TelnetClient.getInputStream.write() causes
> > SocketTimeOutException immediately
> > 
> > 
> > Hi,
> >  
> > Making use of the commons.net.telnet.TelnetClient, we've set 
> > up a connection with a Telnet Daemon.
> > It works fine to send a message to the Telnet Daemon by using 
> > an OutputStream and receive a response by using a BufferedReader.
> > The SoTimeout was set to 15 seconds.
> >  
> > But if we haven't send/received anything for appr. 20 seconds 
> > the next first message is send to the Outputstream, but the 
> > BufferedReader.read() immediately throws a SocketTimeOutException!
> > A retry 'read()' to the same instance of the BufferredReader 
> > succeeds (without setting up a new connection).
> >  
> > Strange enough this does not happen if the Telnet 
> > Communication 'sleeps' for less than 10 seconds, but only if 
> > no communication has been there for longer than 20 seconds.
> >  
> > We receive the following stacktrace:
> > Stacktrace {
> >         java.net.SocketTimeoutException: Read timed out
> >                  at 
> > java.net.SocketInputStream.socketRead0(Native Method)
> >                  at 
> > java.net.SocketInputStream.read(SocketInputStream.java:129)
> >                  at 
> > java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
> >                  at 
> > java.io.BufferedInputStream.read(BufferedInputStream.java:201)
> >                  at 
> > java.io.FilterInputStream.read(FilterInputStream.java:66)
> >                  at 
> > java.io.PushbackInputStream.read(PushbackInputStream.java:120)
> >                  at 
> > org.apache.commons.net.io.FromNetASCIIInputStream.__read(FromN
> > etASCIIInputStream.java:75)
> >                  at 
> > org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNet
> > ASCIIInputStream.java:170)
> >                  at 
> > java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
> >                  at 
> > java.io.BufferedInputStream.read(BufferedInputStream.java:201)
> >                  at 
> > org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetI
> > nputStream.java:114)
> >                  at 
> > org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInpu
> > tStream.java:535)
> >                  at java.lang.Thread.run(Thread.java:534)
> > }
> > 
> > Does anybody have a clue in which direction to look for a solution?
> >  
> > Thanks,
> > Peter
> >  
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

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


Mime
View raw message