[jcifs] java.io.IOException: Failed to establish session

Michael B Allen ioplex at gmail.com
Sat Jun 13 00:51:12 MDT 2015

On Fri, Jun 12, 2015 at 4:35 PM, Shon Vella <svella at idauto.net> wrote:
> I have a customer that is seeing this exact problem. In his case it appears
> that CALLED_NOT_PRESENT is a result of not being able to properly resolve
> the ip address to the netbios name so we're working on making sure that the
> right name is available.
> With regards to M.D.'s proposed solution, it isn't quite right. ssn139()
> loops through the available names for the address, so resetting the port to
> 445 on the first CALLED_NOT_PRESENT or NOT_LISTENING_CALLED would be
> premature. It need to wait at least until the loop exit, which only happens
> after all the names have been tried, though I'm not sure even there is the
> right place. I think if it were me I would put the error code in a variable
> outside the loop, and then if I even completed the loop, rather than throw
> IOError, I would throw NbtException using that error code rather than
> throwing IOError. I would than add a catch of NbtException doConnect and
> handle it similarly to ConnectException and NoRouteToHostException when the
> code is CALLED_NOT_PRESENT or NOT_LISTENING_CALLED. It also seems that an
> invalid or incomplete nbt response (e.g. the EOF case) might be also be a
> good excuse to try 445 again.

I think the best solution would be to just add a
jcifs.smb.client.port139.enabled property which defaults to false and
causes the connection op to throw an exception instead of trying to
failover to 139.

I don't think there any any legit servers using port 139 anymore. It
was relevant 15 years ago when some old networks had not quite opened
up port 445. I don't want to mess with trying to account for the
various race conditions surrounding the port 139 failover logic.


Michael B Allen
Java Active Directory Integration

More information about the jCIFS mailing list