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

Patrik Ek commented on SSHD-968:
--------------------------------

Hi,

This seems to work. 

2020-02-28T15:49:40,218 DEBUG  
request(ClientSessionImpl[root@/192.168.10.220:830]) 
[email protected], timeout=5000 MILLISECONDS
2020-02-28T15:49:40,218 DEBUG  
preProcessEncodeBuffer(ClientSessionImpl[root@/192.168.10.220:830]) outgoing 
SSH_MSG_GLOBAL_REQUEST seqNo=-1 => 16
2020-02-28T15:49:40,218 DEBUG  
encode(ClientSessionImpl[root@/192.168.10.220:830]) packet #16 sending 
command=80[SSH_MSG_GLOBAL_REQUEST] len=27
2020-02-28T15:49:40,218 TRACE  
encode(ClientSessionImpl[root@/192.168.10.220:830]) packet #16 [chunk 
#1](27/27) 50 00 00 00 15 6b 65 65 70 61 6c 69 76 65 40 6f 70 65 6e 73 73 68 2e 
63 6f 6d 01                                                                     
                                              [email protected].
2020-02-28T15:49:40,218 TRACE  
encode(ClientSessionImpl[root@/192.168.10.220:830]) packet #16 
command=80[SSH_MSG_GLOBAL_REQUEST] len=44, pad=16, mac=BaseMac[HmacSHA256] -  
block=32/32 bytes, encrypt-then-mac=false
2020-02-28T15:49:40,218 DEBUG  
writePacket(Nio2Session[local=/0:0:0:0:0:0:0:0:59756, 
remote=/192.168.10.220:830]) Writing 80 bytes
2020-02-28T15:49:40,218 DEBUG  
request(ClientSessionImpl[root@/192.168.10.220:830])[[email protected]] 
sent with seqNo=16
2020-02-28T15:49:40,218 TRACE  
request(ClientSessionImpl[root@/192.168.10.220:830])[[email protected]] 
remaining wait=5000
2020-02-28T15:49:40,219 DEBUG  
handleCompletedWriteCycle(Nio2Session[local=/0:0:0:0:0:0:0:0:59756, 
remote=/192.168.10.220:830]) finished writing len=80
2020-02-28T15:49:40,222 DEBUG  
handleReadCycleCompletion(Nio2Session[local=/0:0:0:0:0:0:0:0:59756, 
remote=/192.168.10.220:830]) read 48 bytes
2020-02-28T15:49:40,222 TRACE  
decode(ClientSessionImpl[root@/192.168.10.220:830]) packet #59 [chunk #1](5/5) 
03 00 00 00 10                                                                  
                                                                                
                                   .....
2020-02-28T15:49:40,222 TRACE  
doHandleMessage(ClientSessionImpl[root@/192.168.10.220:830]) process 
SSH_MSG_UNIMPLEMENTED
2020-02-28T15:49:40,222 DEBUG  
doInvokeUnimplementedMessageHandler(ClientSessionImpl[root@/192.168.10.220:830])
 report global [email protected] failure for seqNo=16
2020-02-28T15:49:40,222 DEBUG  
request(ClientSessionImpl[root@/192.168.10.220:830]) 
[email protected], timeout=5000 MILLISECONDS, requestSeqNo=16, 
result received=true

{color:#172b4d}Feel free to merge whenever you want. Thanks for the quick 
support.{color}

BR
Patrik

> SshClient times out during keep-alive, when SSH_MSG_GLOBAL_REQUEST is replied 
> with SSH_MSG_UNSUPPORTED
> ------------------------------------------------------------------------------------------------------
>
>                 Key: SSHD-968
>                 URL: https://issues.apache.org/jira/browse/SSHD-968
>             Project: MINA SSHD
>          Issue Type: Improvement
>    Affects Versions: 2.3.0
>         Environment: Windows 10
>            Reporter: Patrik Ek
>            Assignee: Lyor Goldstein
>            Priority: Major
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> In case SSH_MSG_GLOBAL_REQUEST is not supported by the remote SSH server, the 
> keep-alive heartbeat times out. The reason for this is SSH_MSG_UNIMPLEMENTED 
> is only logged in
> {color:#172b4d}org.apache.sshd.common.session.helpers{color}.AbstractSession
> The method identifying the SSH_MSG_UNIMPLEMENTED is called 
> AbstractSession.doHandleMessage()
> The consequense is that no reply is received and the heartbeat times out 
> instead of calling AbstractSession.requestFailure(). Which in turn leads to 
> the session terminates.
> According to RFC 4253 sect. 11.4 
> ({color:#004000}https://tools.ietf.org/html/rfc4253#section-11.4{color}) the 
> SSH_MSG_UNIMPLEMENTED is meant to be ignored, but this makes little sense for 
> a heartbeat, as even SSH_MSG_UNIMPLEMENTED is good enough to count as a reply 
> for this. This is for example the case in OpenSSH, where 
> SSH_MSG_UNIMPLEMENTED replies for heartbeat, does not lead to a termination 
> of the SSH session.
> There is a workaround released in 2.1.1, to use 
> ReservedSessionMessagesHandler for handling replies, but this does not allow 
> access to the method AbstractSession.requestFailure() (without using 
> reflection so to say). Further, the heartbeat is ongoing in the background, 
> so there is no good solution to this problem from outside of the framework.
> https://issues.apache.org/jira/browse/SSHD-887?jql=project%20%3D%20SSHD%20AND%20fixVersion%20%3D%202.1.1
> Would this be possible to fix? The reason I write it here is because the bug 
> seems to existing up to some version of libssh, even for the SSHv2 protocol, 
> so just writing a bug report on the particular server will not solve the 
> problems for already existing implementations using libssh.
> The following config is used,
> SshClient client = 
> SshClient.setUpDefaultClient(){color:#cc7832};{color}{color:#808080}
> {color} {color:#172b4d}PropertyResolverUtils.updateProperty(client, 
> ClientFactoryManager.HEARTBEAT_INTERVAL, 15000);
>  
> PropertyResolverUtils.updateProperty(client,ClientFactoryManager.HEARTBEAT_REPLY_WAIT,
>  30000);
>  
> PropertyResolverUtils.updateProperty(client,ClientFactoryManager.HEARTBEAT_REQUEST,
>  "[email protected]");{color}
> {color:#cc7832}{color:#172b4d}BR{color}
> {color:#172b4d}Patrik{color}
> {color}



--
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