Not sure if this is even an issue or if configuring a custom SO_TIMEOUT doesn't make sense at all. Setting a SO_TIMEOUT > 0 for the DirectTcpTransport socket causes the packet reader to discard the connection when idling.
2023-09-01 11:21:21,915 [Packet Reader for u365396.your-storagebox.de] INFO com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader - PacketReader error, got exception.
com.hierynomus.protocol.transport.TransportException: java.net.SocketTimeoutException: Read timed out
at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.doRead(DirectTcpPacketReader.java:53) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.PacketReader.readPacket(PacketReader.java:70) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:48) [smbj-0.12.2.jar:0.12.2]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.net.SocketTimeoutException: Read timed out
at sun.nio.ch.NioSocketImpl.timedRead(Unknown Source) ~[?:?]
at sun.nio.ch.NioSocketImpl.implRead(Unknown Source) ~[?:?]
at sun.nio.ch.NioSocketImpl.read(Unknown Source) ~[?:?]
at sun.nio.ch.NioSocketImpl$1.read(Unknown Source) ~[?:?]
at java.net.Socket$SocketInputStream.read(Unknown Source) ~[?:?]
at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.readFully(DirectTcpPacketReader.java:70) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.readTcpHeader(DirectTcpPacketReader.java:59) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader.doRead(DirectTcpPacketReader.java:48) ~[smbj-0.12.2.jar:0.12.2]
... 3 more
This will however trigger to logoff the session and close any opened shares which will always fail because the transport is already closed and cause further exceptions.
2023-09-01 11:22:40,934 [Packet Reader for u365396.your-storagebox.de] INFO com.hierynomus.smbj.session.Session - Logging off session 2623478559 from host u365396.your-storagebox.de
2023-09-01 11:22:48,667 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.connection.Connection - Granted 1 (out of 609) credits to Signed(SMB2_TREE_DISCONNECT with message id << 56 >>)
2023-09-01 11:22:48,669 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport - Writing packet Signed(SMB2_TREE_DISCONNECT with message id << 56 >>)
2023-09-01 11:22:48,673 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.protocol.commons.concurrent.Promise - Awaiting << 56 >>
2023-09-01 11:22:58,680 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.session.Session - Notified of TreeDisconnected <<1273785734>>
2023-09-01 11:23:17,050 [Packet Reader for u365396.your-storagebox.de] ERROR com.hierynomus.smbj.session.Session - Caught exception while closing TreeConnect with id: 1273785734
com.hierynomus.protocol.transport.TransportException: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:30) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:24) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:47) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.share.TreeConnect.close(TreeConnect.java:70) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.share.Share.close(Share.java:116) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.session.Session.logoff(Session.java:236) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.session.Session.close(Session.java:279) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.close(Connection.java:178) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.close(Connection.java:155) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.handleError(Connection.java:295) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:54) [smbj-0.12.2.jar:0.12.2]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:59) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 9 more
Caused by: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:28) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:22) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 9 more
Caused by: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 9 more
2023-09-01 11:23:25,837 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.connection.Connection - Granted 1 (out of 608) credits to Signed(SMB2_LOGOFF with message id << 57 >>)
2023-09-01 11:23:25,871 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport - Writing packet Signed(SMB2_LOGOFF with message id << 57 >>)
2023-09-01 11:23:25,881 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.protocol.commons.concurrent.Promise - Awaiting << 57 >>
2023-09-01 11:23:45,185 [Packet Reader for u365396.your-storagebox.de] DEBUG com.hierynomus.smbj.connection.Connection - Session << 2623478559 >> logged off
2023-09-01 11:23:49,656 [Packet Reader for u365396.your-storagebox.de] WARN com.hierynomus.smbj.connection.Connection - Exception while closing session 2623478559
com.hierynomus.protocol.transport.TransportException: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:30) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.transport.TransportException$1.wrap(TransportException.java:24) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:47) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.session.Session.logoff(Session.java:256) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.session.Session.close(Session.java:279) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.close(Connection.java:178) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.close(Connection.java:155) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.connection.Connection.handleError(Connection.java:295) [smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:54) [smbj-0.12.2.jar:0.12.2]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.util.concurrent.ExecutionException: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:59) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 7 more
Caused by: com.hierynomus.smbj.common.SMBRuntimeException: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:28) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.smbj.common.SMBRuntimeException$1.wrap(SMBRuntimeException.java:22) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 7 more
Caused by: java.util.concurrent.TimeoutException: Timeout expired
at com.hierynomus.protocol.commons.concurrent.Promise.retrieve(Promise.java:136) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.PromiseBackedFuture.get(PromiseBackedFuture.java:57) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.CancellableFuture.get(CancellableFuture.java:84) ~[smbj-0.12.2.jar:0.12.2]
at com.hierynomus.protocol.commons.concurrent.Futures.get(Futures.java:42) ~[smbj-0.12.2.jar:0.12.2]
... 7 more
Not sure if this is even an issue or if configuring a custom SO_TIMEOUT doesn't make sense at all. Setting a SO_TIMEOUT > 0 for the
DirectTcpTransport
socket causes the packet reader to discard the connection when idling.This will however trigger to logoff the session and close any opened shares which will always fail because the transport is already closed and cause further exceptions.