Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeepAlive threads don't die if authPassword fails #506

Open
adagios opened this issue Apr 12, 2019 · 1 comment
Open

KeepAlive threads don't die if authPassword fails #506

adagios opened this issue Apr 12, 2019 · 1 comment

Comments

@adagios
Copy link
Contributor

adagios commented Apr 12, 2019

When there's an EOF during authPassword(), the KeepAlive thread is not stopped, and because the transport is not running, just keeps sleeping on an infinite loop.

An example of the logs I'm seeing:

2019-04-11 23:50:38,839 ERROR [[reader]] (()) 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:59)
2019-04-11 23:50:38,839  INFO [[reader]] (()) net.schmizz.sshj.transport.TransportImpl : Disconnected - UNKNOWN
2019-04-11 23:50:38,843 ERROR [[interact-486]] (()) net.schmizz.concurrent.Promise : <<authenticated>> woke to: net.schmizz.sshj.userauth.UserAuthException: Broken transport; encountered EOF

I'm trying to work around it by switching the order of autoPassword and turning the KeepAlive on, from the order given in the KeepAlive example:

client.connect(ip, port);
client.getConnection().getKeepAlive().setKeepAliveInterval(timeoutInSeconds);
client.authPassword(user, password);

to

client.connect(ip, port);
client.authPassword(user, password);
client.getConnection().getKeepAlive().setKeepAliveInterval(timeoutInSeconds);

will update when I find out the results.

@adagios
Copy link
Contributor Author

adagios commented Apr 16, 2019

The switch seems to have resolved the hang thread on that occasion, but it now seems that there are other times when the keep-alive (and even the reader thread) are kept well after they should have stopped.

Still trying to gather more information / reduce the problem.

exceptionfactory added a commit to exceptionfactory/sshj that referenced this issue Dec 21, 2021
…ierynomus#506)

- Changed KeepAlive.setKeepAliveInterval() to avoid starting Thread
- Updated SSHClient.onConnect() to start KeepAlive Thread when enabled
- Updated SSHClient.disconnect() to interrupt KeepAlive Thread
- Updated KeepAliveThreadTerminationTest to verify state of KeepAlive Thread
hierynomus added a commit that referenced this issue Dec 22, 2021
) (#752)

- Changed KeepAlive.setKeepAliveInterval() to avoid starting Thread
- Updated SSHClient.onConnect() to start KeepAlive Thread when enabled
- Updated SSHClient.disconnect() to interrupt KeepAlive Thread
- Updated KeepAliveThreadTerminationTest to verify state of KeepAlive Thread

Co-authored-by: Jeroen van Erp <jeroen@hierynomus.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant