You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Lyor Goldstein (Jira)" <ji...@apache.org> on 2020/12/04 08:57:00 UTC

[jira] [Comment Edited] (SSHD-1085) channel.waitFor() get stuck when run reboot command

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

Lyor Goldstein edited comment on SSHD-1085 at 12/4/20, 8:56 AM:
----------------------------------------------------------------

I don't think we can predict how rebooting affects an ongoing TCP connection - specifically for this issue the exit status is a value being sent +explicitly+ by the server. However, the server is "rudely" interrupted by the reboot - of which the server is unaware. I therefore think that expecting any kind of exit status seem a bit of a stretch.

As to the NPE - please note that the API clearly indicates that a _null_ is allowed - not only if connection was lost, but also because sending an exit status is +optional+ - according to [RFC 4254 - section 6.10|https://tools.ietf.org/html/rfc4254#section-6.10]
{quote}The following message can be sent to return the exit status of the command. Returning the status is RECOMMENDED.
{quote}
I.e., it can happen not only for reboot but also for the server not sending such a status.


was (Author: lgoldstein):
I don't think we can predict how rebooting affects an ongoing TCP connection - specifically for this issue the exit status is a value being sent +explicitly+ by the server. However, the server is "rudely" interrupted by the reboot - of the server is unaware. I therefore think that expecting any kind of exit status seem a bit of a stretch.

As to the NPE - please note that the API clearly indicates that a _null_ is allowed - not only if connection was lost, but also because sending an exit status is +optional+ - according to [RFC 4254 - section 6.10|https://tools.ietf.org/html/rfc4254#section-6.10]
{quote}The following message can be sent to return the exit status of the command. Returning the status is RECOMMENDED.
{quote}
I.e., it can happen not only for reboot but also for the server not sending such a status.

> 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: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org