You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JSch SSH tunnel implementation is not robust, it has no reconnect logic and it doesn't provide callbacks for connection issues.
See the following log showing tunnel socket failures:
root@013a466:~# balena logs -t 063 2>&1 | grep "Caught an exception"
2026-01-16T14:24:18.887695000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T14:33:25.701403000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T14:46:57.166493000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T15:05:06.878513000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T15:20:36.394997000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T15:35:02.652126000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T15:50:37.032995000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T15:54:41.633763000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T16:07:09.490565000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
2026-01-16T16:25:01.597533000Z INFO [Connect thread staging.v..sion] com.jcraft.jsch.JSch : Caught an exception, leaving main loop due to Socket closed
Two steps required to improve this:
Implement callbacks for underlying connection changes
Think I will try the Apache MINA SSHD client for more widespread support and hopefully less risk of becoming unsupported, just don't know how heavy this library is.
Activity
richturner commentedon Jan 16, 2026
Let's look at moving to https://github.com/hierynomus/sshj
ebariaux commentedon Jan 19, 2026
There's also https://github.com/sshtools/maverick-synergy but it has a commercial license part (https://jadaptive.com/java-ssh-library/), not sure how that would impact us.
And never used it.
richturner commentedon Jan 19, 2026
Think I will try the Apache MINA SSHD client for more widespread support and hopefully less risk of becoming unsupported, just don't know how heavy this library is.