hierynomus / smbj

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

Idle session exception #560

Closed felixRajkumar closed 3 years ago

felixRajkumar commented 4 years ago

com.hierynomus.protocol.transport.TransportException: java.net.SocketException: Connection reset by peer: socket write error at com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport.write(DirectTcpTransport.java:78) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.connection.Connection.send(Connection.java:399) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.session.Session.send(Session.java:322) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.share.TreeConnect.sendBySession(TreeConnect.java:140) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.share.TreeConnect.close(TreeConnect.java:82) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.share.Share.close(Share.java:115) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.session.Session.logoff(Session.java:242) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.session.Session.close(Session.java:292) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.connection.Connection.close(Connection.java:155) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.connection.Connection.close(Connection.java:140) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.connection.Connection.handleError(Connection.java:576) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at com.hierynomus.smbj.transport.PacketReader.run(PacketReader.java:54) [smbj-0.1.0.jar:0.1.0-SNAPSHOT] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] Caused by: java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) ~[?:1.8.0_51] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) ~[?:1.8.0_51] at java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[?:1.8.0_51] at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[?:1.8.0_51] at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) ~[?:1.8.0_51] at com.hierynomus.smbj.transport.tcp.direct.DirectTcpTransport.write(DirectTcpTransport.java:75) ~[smbj-0.1.0.jar:0.1.0-SNAPSHOT] ... 12 more

Hi, I am getting the following exception, I think this issue is due to idle sessions. Is there any way to fix it. I have tried withSoTimeOut It didnt work.

The following is the smbconfig

smbConfig = SmbConfig .builder() .withSoTimeout(1, TimeUnit.DAYS) .withMultiProtocolNegotiate(true) .withEncryptData(true) .build();

ecki commented 4 years ago

The so timeout influences the local socket setting, if the server closes the connection (like the exception suggests) you cannot influence that. Your application probably needs to implement closing idle sessions or regularly using the session and/or retries.