[ 
https://issues.apache.org/jira/browse/SSHD-1085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17243855#comment-17243855
 ] 

Lyor Goldstein commented on SSHD-1085:
--------------------------------------

{quote}
based on your comment, SSHD clientSession cannot detect the channel status? if 
the remote sshd server is down or whole server cannot reachable, I think there 
must be a way to detect the TCP connection status.
{quote}
I think you are confusing channel +TCP+ status - which depends on whether there 
is a viable ongoing connection  with channel exit status - which is a 
+protocol+ construct. They are distinct "status" though we use the same word.

{quote}
I still dont think throw the NULL
{quote}
I think you are not describing correctly the code flow - our code does not 
throw NPE +your+ code does because you are treating an {{Integer}} which the 
documentation clearly states that can be null as if it isn't. 
{quote}
We also use JSCH with the same reboot command to remote node, JSCH can handle 
correctly. 
I feel JSCH can handle the channel status more robust, while Mina SSHD has 
problem to handle the channel status.
{quote}
I don't really understand your definition of "correctly" - can you clarify what 
you think is "correct" and what is "incorrect" ? Can you provide some reference 
standard documentation for the definition ?

{quote}
hope when I give follow: EnumSet.of(ClientChannelEvent.CLOSED, 
ClientChannelEvent.EXIT_STATUS,ClientChannelEvent.EXIT_SIGNAL, 
ClientChannelEvent.EOF) for the mask, so the AbstractClientChannel.waitFor() 
will return if found any above status, not only just look for CLOSED.
{quote}
You should get the {{CLOSED}} event but I would be very surprised if you get 
any exit status - so check for null and don't assume.

> channel.waitFor() get stuck when run reboot command
> ---------------------------------------------------
>
>                 Key: SSHD-1085
>                 URL: https://issues.apache.org/jira/browse/SSHD-1085
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.5.1
>         Environment: linux
>            Reporter: min yun law
>            Priority: Minor
>
> Trying to run linux command "reboot" by mina sshd to remote node, the node is 
> in reboot, but the ClientChannel object still keep open, not in closed 
> status, Here is the logic code in my project:
>  
> {code:java}
> String command = "reboot";
> ChannelExec channel = clientSession.createExecChannel(command);
> if(!channel.isClosed())
> {
> ByteArrayOutputStream out = new ByteArrayOutputStream(); 
> ByteArrayOutputStream err = new ByteArrayOutputStream(); channel.setOut(out); 
> channel.setErr(err); 
> channel.open().await();  //this passed 
> //follow call will cause stuck 
> Collection<ClientChannelEvent> waitMask = 
> channel.waitFor(REMOTE_COMMAND_WAIT_EVENTS, 0L);  
> String outputStr = new String(out.toByteArray(), StandardCharsets.UTF_8); 
> //some case this will throw runtime exception
>  int exitStatus = channel.getExitStatus(); 
> }
>  
> {code}
>  
> So why the ChannelExec cannot get the correct channel status when remote node 
> is rebooting?
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to