Search code examples
javamultithreadingsshj2ssh

Thread blocked while disconnect NETCONF session in J2SSH


I have used J2ssh library (0.2.7) to establish NETCONF connection in my application. While profile monitoring I noticed that few threads got blocked in disconnect() of j2ssh session. It is not a consistent issue, it happens at times.

I have given below the stack trace.

Thread-116 (HornetQ-client-global-threads-1530142454) - priority:10 - threadId:0x00007f7e34065000 - nativeId:0x75aa - state:BLOCKED
stackTrace:
java.lang.Thread.State: BLOCKED (on object monitor)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendMessage(Unknown Source)
- waiting to lock <0x0000000600164f20> (a com.sshtools.j2ssh.transport.TransportProtocolClient)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendDisconnect(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.disconnect(Unknown Source)
at com.sshtools.j2ssh.SshClient.disconnect(Unknown Source)
at com.test.server.protocol.communication.MyNetconfSession.close(MyNetconfSession.java:106)

Solution

  • You are using an SSH library that has not been maintained for 10 years. If this is a problem it will never be fixed.

    For security reasons you should upgrade to the replacement library at https://github.com/sshtools/j2ssh-maverick

    It's likely the problem will not exist in the new version, but at least if there is you can report an issue as the project is still active.