hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
713 stars 180 forks source link

Hanging thread after `SocketTimeoutException` in `DirectTcpPacketReader` #677

Open heyalistair opened 3 years ago

heyalistair commented 3 years ago

I'm getting an unrecoverable and hanging thread when there is a read timeout.

2021-09-24T16:16:58.622428896+01:00 stdout F  [30m2021-09-24 15:16:58,621 [0;39m  [34mINFO  [0;39m  [ [34mPacket Reader for ***************** [0;39m]  [33mcom.hierynomus.smbj.transport.PacketReader:53 [0;39m: PacketReader error, got exception.
2021-09-24T16:16:58.622428896+01:00 stdout F com.hierynomus.protocol.transport.TransportException: java.net.SocketTimeoutException: Read timed out
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.doRead(DirectTcpPacketReader.java:53)
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.PacketReader.readPacket(PacketReader.java:70)
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:48)
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/java.lang.Thread.run(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F Caused by: java.net.SocketTimeoutException: Read timed out
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/sun.nio.ch.NioSocketImpl.timedRead(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/sun.nio.ch.NioSocketImpl.implRead(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/sun.nio.ch.NioSocketImpl.read(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/sun.nio.ch.NioSocketImpl$1.read(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F    at java.base/java.net.Socket$SocketInputStream.read(Unknown Source)
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.readFully(DirectTcpPacketReader.java:70)
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.readTcpHeader(DirectTcpPacketReader.java:59)
2021-09-24T16:16:58.622428896+01:00 stdout F    at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.doRead(DirectTcpPacketReader.java:48)
2021-09-24T16:16:58.622428896+01:00 stdout F    ... 3 common frames omitted
2021-09-24T16:16:58.622596561+01:00 stdout F  [30m2021-09-24 15:16:58,622 [0;39m  [34mINFO  [0;39m  [ [34mPacket Reader for ***************** [0;39m]  [33mcom.hierynomus.smbj.session.Session:233 [0;39m: Logging off session 167143081508953 from host *****************
2021-09-24T16:18:58.624936264+01:00 stdout F  [30m2021-09-24 15:18:58,624 [0;39m  [1;31mERROR [0;39m  [ [34mPacket Reader for ***************** [0;39m]  [33mcom.hierynomus.smbj.session.Session:238 [0;39m: Caught exception while closing TreeConnect with id: 1
2021-09-24T16:18:58.624936264+01:00 stdout F com.hierynomus.protocol.transport.TransportException: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:30)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:24)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:47)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.share.TreeConnect.close(TreeConnect.java:70)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.share.Share.close(Share.java:115)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.session.Session.logoff(Session.java:236)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.session.Session.close(Session.java:279)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.close(Connection.java:168)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.close(Connection.java:145)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.handleError(Connection.java:284)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:54)
2021-09-24T16:18:58.624936264+01:00 stdout F    at java.base/java.lang.Thread.run(Unknown Source)
2021-09-24T16:18:58.624936264+01:00 stdout F Caused by: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:59)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42)
2021-09-24T16:18:58.624936264+01:00 stdout F    ... 9 common frames omitted
2021-09-24T16:18:58.624936264+01:00 stdout F Caused by: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:28)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:22)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136)
2021-09-24T16:18:58.624936264+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57)
2021-09-24T16:18:58.624936264+01:00 stdout F    ... 11 common frames omitted
2021-09-24T16:18:58.624936264+01:00 stdout F Caused by: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:18:58.624936264+01:00 stdout F    ... 13 common frames omitted
2021-09-24T16:20:58.627037475+01:00 stdout F  [30m2021-09-24 15:20:58,626 [0;39m  [31mWARN  [0;39m  [ [34mPacket Reader for ***************** [0;39m]  [33mcom.hierynomus.smbj.connection.Connection:170 [0;39m: Exception while closing session 167143081508953
2021-09-24T16:20:58.627037475+01:00 stdout F com.hierynomus.protocol.transport.TransportException: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:30)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:24)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:47)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.session.Session.logoff(Session.java:256)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.session.Session.close(Session.java:279)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.close(Connection.java:168)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.close(Connection.java:145)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.connection.Connection.handleError(Connection.java:284)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:54)
2021-09-24T16:20:58.627037475+01:00 stdout F    at java.base/java.lang.Thread.run(Unknown Source)
2021-09-24T16:20:58.627037475+01:00 stdout F Caused by: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:59)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42)
2021-09-24T16:20:58.627037475+01:00 stdout F    ... 7 common frames omitted
2021-09-24T16:20:58.627037475+01:00 stdout F Caused by: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:28)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:22)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136)
2021-09-24T16:20:58.627037475+01:00 stdout F    at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57)
2021-09-24T16:20:58.627037475+01:00 stdout F    ... 9 common frames omitted
2021-09-24T16:20:58.627037475+01:00 stdout F Caused by: java.util.concurrent.TimeoutException: Timeout expired
2021-09-24T16:20:58.627037475+01:00 stdout F    ... 11 common frames omitted
2021-09-24T16:20:58.627185855+01:00 stdout F  [30m2021-09-24 15:20:58,627 [0;39m  [34mINFO  [0;39m  [ [34mPacket Reader for ***************** [0;39m]  [33mcom.hierynomus.smbj.connection.Connection:176 [0;39m: Closed connection to *****************

(Sorry the logs are a little sloppy.)

This is how I create an SMBClient:

    SMBClient client = new SMBClient(SmbConfig.builder()
        .withSecurityProvider(new BCSecurityProvider())
        .withDfsEnabled(true)
        .withTimeout(120, TimeUnit.SECONDS)
        .withSoTimeout(120, TimeUnit.SECONDS)
        .build());

I'm connecting to a downloading around 2000 files from a Windows 2016 Server. I'm running 0.11.1.

Any tips? Please let me know if you would like more information.