Connection timeout, then the transport stays "in error"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Connection timeout, then the transport stays "in error"

Tom Shaw-3
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,flags=0x0018,flags2=0xC003,signSeq=0,tid=0,pid=28490,uid=0,mid=920,wordCount=13,byteCount=95,andxCommand=0x75,andxOffset=156,snd_buf_size=16644,maxMpxCount=10,VC_NUMBER=1,sessionKey=0,passwordLength=24,unicodePasswordLength=24,capabilities=84,accountName=20013059,primaryDomain=?,NATIVE_OS=SunOS,NATIVE_LANMAN=jCIFS]
        at jcifs.util.transport.Transport.sendrecv(Transport.java:74)
        at jcifs.smb.SmbTransport.send(SmbTransport.java:580)
        at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:264)
        at jcifs.smb.SmbSession.send(SmbSession.java:223)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:144)
        at jcifs.smb.SmbFile.connect(SmbFile.java:792)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:762)
        at jcifs.smb.SmbFile.send(SmbFile.java:660)
        at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1684)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1575)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1539)
...


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)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:129)
        at jcifs.smb.SmbFile.connect(SmbFile.java:792)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:762)
        at jcifs.smb.SmbFile.send(SmbFile.java:660)
        at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1684)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1575)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1539)
...
        at jcifs.util.transport.Transport.connect(Transport.java:155)
        at jcifs.smb.SmbTransport.connect(SmbTransport.java:271)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:129)
        at jcifs.smb.SmbFile.connect(SmbFile.java:792)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:762)
        at jcifs.smb.SmbFile.send(SmbFile.java:660)
        at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1684)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1575)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1539)
...
        at jcifs.smb.SmbTransport.connect(SmbTransport.java:273)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:129)
        at jcifs.smb.SmbFile.connect(SmbFile.java:792)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:762)
        at jcifs.smb.SmbFile.send(SmbFile.java:660)
        at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1684)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1575)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1539)

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?

Regards
Tom Shaw
Reply | Threaded
Open this post in threaded view
|

Re: Connection timeout, then the transport stays "in error"

Michael B Allen-4
On Tue, 15 Nov 2005 15:19:53 +0800
Tom Shaw <[hidden email]> 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