Recently, our project used the Jsch library when developing remote node management. When the test found that a node after the execution of the CMD, channel.isclosed () has been false, resulting in the request can not be returned, but some other nodes are not related, the direct execution is normal, the return code is identical. Google has not found a solution such as https://github.com/lucastheisen/jsch-extension/issues/6,https://stackoverflow.com/ Questions/12138777/jsch-channel-never-closed-or-eof (plus exit does not work), after careful research and analysis, and post https://sourceforge.net/p/jsch/ MAILMAN/MESSAGE/24270241/, there may indeed be cases where the channel cannot detect close. Final Workaround:
Judging whether the Channel.exitstatus is 0, 0 represents the normal end, because 1 means the command has not been executed. Follow-up observation to see if there are any other incorrect false positives.
Reference:
https://sourceforge.net/p/jsch/mailman/jsch-users/thread/4B39D620.30006%40i4s.co.jp/#msg24270241
Jsch:channel never closed or EOF channel not closed