Re: java.io.IOException: Failed to establish session
"M. D." <[email protected]> Tue, 17 Mar 2015 13:52:17 +0200 (EET)
| Newsgroups | gmane.network.samba.java |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I think I found the cause for the=20
jcifs.util.transport.TransportException=20
java.io.IOException: Failed to establish session with 0.0.0.0<00>/192.168=
.0.110=20
at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:284)=20
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:294)=20
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:367)=20
at jcifs.util.transport.Transport.run(Transport.java:241)=20
at java.lang.Thread.run(Thread.java:856)=20
at jcifs.util.transport.Transport.run(Transport.java:258)=20
exception which causes jcifs to be unable to recover from loss of connect=
ivity/networking issues under heavy load.
Imagine the following scenario:
1. Unplug the network cable.
2. jcifs.smb.SmbTransport#doConnect() -> the first negotiate() is called =
with port 445
3. jcifs.smb.SmbTransport#negotiate() fails on port 445 with ConnectExcep=
tion/NoRouteToHostException
4. Plug the cable back
5. The ConnectException/NoRouteToHostException is catched back in the Smb=
Transport#doConnect() method. A second negotiate() attempt is made over p=
ort 139.
6. The SmbTransport#ssn139() socket.connect is successful because the con=
nectivity is restored. In some rare cases (I still haven't figured out wh=
y) the remote host can reply with NetBT session response containing error=
code CALLED_NOT_PRESENT or NOT_LISTENING_CALLED.
7. The socket is closed and the following exception is thrown:
jcifs.util.transport.TransportException=20
java.io.IOException: Failed to establish session with 0.0.0.0<00>/192.168=
.0.110=20
at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:284)=20
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:294)=20
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:367)=20
at jcifs.util.transport.Transport.run(Transport.java:241)=20
at java.lang.Thread.run(Thread.java:856)=20
at jcifs.util.transport.Transport.run(Transport.java:258)=20
8. The transport gets disconnected.
9. Transport#connect() is executed by some client. A new transport thread=
is started that does doConnect()
10. The doConnect() first attempts negotiate() on port 139. But it fails =
again with CALLED_NOT_PRESENT
11. The following exception is thrown again:
jcifs.util.transport.TransportException=20
java.io.IOException: Failed to establish session with 0.0.0.0<00>/192.168=
.0.110=20
at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:284)=20
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:294)=20
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:367)=20
at jcifs.util.transport.Transport.run(Transport.java:241)=20
at java.lang.Thread.run(Thread.java:856)=20
at jcifs.util.transport.Transport.run(Transport.java:258)=20
12. Since this is IOException and not ConnectException/NoRouteToHostExcep=
tion the doConnect() never catches this exception and the port is not res=
tored back to 445.
13. Steps 8-12 are repeated endlessly until the remote server stop replyi=
ng with CALLED_NOT_PRESENT or the ssn139() socket.connect() fails with Co=
nnectException or NoRouteToHostException in which case the port is set ba=
ck to 445.
Mike, what do you think? Imho you should add a line in SmbTransport#ssn13=
9():
switch (errorCode) {
case NbtException.CALLED_NOT_PRESENT:
case NbtException.NOT_LISTENING_CALLED:
socket.close();
port =3D 445; // set back port 445
break;
Best regards,
M.D.
>-------- =D0=9E=D1=80=D0=B8=D0=B3=D0=B8=D0=BD=D0=B0=D0=BB=D0=BD=D0=BE =D0=
=BF=D0=B8=D1=81=D0=BC=D0=BE --------
>=D0=9E=D1=82: M. D. =20
>=D0=9E=D1=82=D0=BD=D0=BE=D1=81=D0=BD=D0=BE: java.io.IOException: Failed=
to establish session
>=D0=94=D0=BE: [email protected], [email protected], MSedliak@s=
oftip.sk,=20
[email protected]
>=D0=98=D0=B7=D0=BF=D1=80=D0=B0=D1=82=D0=B5=D0=BD=D0=BE =D0=BD=D0=B0: =D0=
=A7=D0=B5=D1=82=D0=B2=D1=8A=D1=80=D1=82=D1=8A=D0=BA, 2015, =D0=9C=D0=B0=D1=
=80=D1=82 12 11:12:00 EET
>
>
> Hello Adam, Mike, Everyone
>
>
Have you had any luck discovering the root cause for this issue?
>
>
I posted a few months ago on the mailing list. One of our customers suffe=
rs from exactly the same issue but we're currently not able to reproduce =
it on our side.
>
https://lists.samba.org/archive/jcifs/2014-October/010188.html
>
The same issue reported a long time ago by other users:=20
>
http://samba.2283325.n4.nabble.com/Failed-to-establish-session-td2512348.=
html#a2512349
>
http://samba.2283325.n4.nabble.com/IOException-at-ssn139-access-print-ser=
ver-td4643959.html
>
>
I just dug up this thread and I see that you suffered from the same thing=
and you were able to debug it locally.=20
>
I know it was a long time ago but do you by any chance remember what was =
the OS of the server machine? Did you use NetBIOS with alternative names =
+ Windows Server 2003 for the server? If that's the case then it might be=
related to:
>
http://support.microsoft.com/kb/940684
>
>
Also, do you remember any details about your environment in general? Any =
tips on how to reproduce that will be appreciated!
>
>
Best regards,
>
M.D.
>
>