[jcifs] Connection timeout, then the transport stays "in error"

Michael B Allen mba2000 at ioplex.com
Tue Nov 15 16:41:07 GMT 2005


On Tue, 15 Nov 2005 15:19:53 +0800
Tom Shaw <tomisfaraway at gmail.com> wrote:

> Hi folks
> 
> We've been running into a problem with jCIFS where a connect() times
> out, and then every subsequent attempt to connect to that particular
> server fails.
> 
> Our application is trying to call listFiles() on a SmbFile directory.
> 
> It's possible that the initial exception is reasonable, because we
> only find it happening to one of our servers which is 1000km away, so
> packet loss may be occurring. The main problem though is that once the
> initial error has occured, jCIFS can't recover from the situation.
> 
> The initial exception is:
> jcifs.smb.SmbException:
> jcifs.util.transport.TransportException: Transport2 timedout waiting
> for response to
> SmbComSessionSetupAndX[command=SMB_COM_SESSION_SETUP_ANDX,received=false,errorCode=0
> 
> Then whenever the application attempts to talk to that server again,
> we get this exception. As far as I can tell, the exception means "this
> transport is in error, and this is what caused it (Connection
> timeout)":
> 
> jcifs.smb.SmbException:
> jcifs.util.transport.TransportException: Connection in error
> jcifs.util.transport.TransportException: Connection timeout
>         at jcifs.util.transport.Transport.connect(Transport.java:175)
>         at jcifs.smb.SmbTransport.connect(SmbTransport.java:271)
> 
> So is this a jCIFS bug or should our application be somehow detecting
> the error and closing/resetting the transport when there's an error in
> connecting?

The way this is supposed to work is that if an error occurs the transport
is flagged in "error". The next attempt to connect on the transport is
returned in error but the transport state is reset to "ground" and the
next attempt should be able to try to connect again.

But I think I see a problem. The state is only reset if the transport's
disconnect method is call but I'm not sure this happends if the transport
never actually connects successfully.

A simple solution is to also reset the state at the top of
jcifs/util/transport/Transport.connect where it returns "Connection in
error". Are you comfortable with modifying the package and trying that?

Mike


More information about the jcifs mailing list