hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.49k stars 600 forks source link

Exception in the reader thread #610

Open srikarn opened 4 years ago

srikarn commented 4 years ago

2020-06-25 17:24:58.485 ERROR 73802 --- [ reader] n.schmizz.sshj.transport.TransportImpl : Dying because - Broken transport; encountered EOF

net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF at net.schmizz.sshj.transport.Reader.run(Reader.java:57) ~[sshj-0.29.0.jar:0.29.0]

Is there a way to handle this error, I couldn't find the ability to set exception handler for this thread.

hierynomus commented 4 years ago

This exception occurs when the server side unexpectedly closes the connection.

rEVOLution-BlackMamba commented 1 year ago

Same issue over here. What can be done?

hierynomus commented 1 year ago

More logs are needed (preferably both client and server side) to determine what went wrong.

rEVOLution-BlackMamba commented 1 year ago

I don't have acces to the server side, and from my part this is the only relevant part of the log. I am usign akka.stream.alpakka.ftp library from my scala code.

hierynomus commented 1 year ago

you would really need to have a trace and preferably server side log to determine what went wrong. As you can imagine from a 2 line stacktrace excerpt with a message Broken transport: unexpected EOF I cannot venture to guess what went wrong in your application

RickardHolgersson commented 1 month ago

Here is a debug trace at least. My guess would be a race condition during close. It only happens ~50% of the times for me.

2024-07-29 16:21:52,949 [main] DEBUG net.schmizz.sshj.connection.channel.AbstractChannel - Sending close
2024-07-29 16:21:52,949 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<chan#0 / close>>
2024-07-29 16:21:52,950 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.connection.channel.AbstractChannel - Got close
2024-07-29 16:21:52,951 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Forgetting `session` channel (#0)
2024-07-29 16:21:52,952 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0 / close>> to `SOME`
2024-07-29 16:21:52,952 [sshj-Reader-xxxx-1722262910417] ERROR net.schmizz.sshj.transport.TransportImpl - Dying because - Broken transport; encountered EOF
net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
    at net.schmizz.sshj.transport.Reader.run(Reader.java:58) [sshj-0.38.0.jar:?]
2024-07-29 16:21:52,955 [sshj-Reader-xxxx-1722262910417] INFO  net.schmizz.sshj.transport.TransportImpl - Disconnected - UNKNOWN
2024-07-29 16:21:52,955 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.transport.KeyExchanger - Got notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
2024-07-29 16:21:52,956 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.AbstractService - Notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
2024-07-29 16:21:52,956 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to null-service
2024-07-29 16:21:52,956 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
2024-07-29 16:21:52,956 [sshj-Reader-xxxx-1722262910417] DEBUG net.schmizz.sshj.transport.Reader - Stopping

Example where it doesn't fail:

2024-07-29 16:23:05,146 [main] DEBUG net.schmizz.sshj.connection.channel.AbstractChannel - Sending close
2024-07-29 16:23:05,146 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<chan#0 / close>>
2024-07-29 16:23:05,146 [sshj-Reader-xxxx-1722262975938] DEBUG net.schmizz.sshj.connection.channel.AbstractChannel - Got close
2024-07-29 16:23:05,146 [sshj-Reader-xxxx-1722262975938] DEBUG net.schmizz.sshj.connection.ConnectionImpl - Forgetting `session` channel (#0)
2024-07-29 16:23:05,162 [sshj-Reader-xxxx-1722262975938] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0 / close>> to `SOME`
2024-07-29 16:23:05,162 [main] INFO  net.schmizz.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION
2024-07-29 16:23:05,162 [main] DEBUG net.schmizz.sshj.AbstractService - Notified of net.schmizz.sshj.transport.TransportException: [BY_APPLICATION] Disconnected
2024-07-29 16:23:05,162 [main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[BY_APPLICATION], msg=[]
2024-07-29 16:23:05,162 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`