[
https://issues.apache.org/jira/browse/SSHD-720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15703148#comment-15703148
]
Claude Warren commented on SSHD-720:
------------------------------------
I updated the example code to use threads as requested. However, I point out
that the issue is on the client side code.
The point is that the server I am trying to talk to in production if paranoid.
So if I hit it with any sort of incorrect command it shuts down the connection.
My example code simulates this by calling sshd.close(); The result is exactly
the result I see in my production code.
I test to see if the session is open before calling createChannel() as shown
below in an extract from the interactWithServer() method.
{code}
if ( !session.isOpen() ) {
System.err.println( "Session invalid on "+command);
throw new SessionInvalidException();
}
System.out.println( "Sending "+command);
channel = session.createChannel(Channel.CHANNEL_EXEC, command);
{code}
I don't see any way to accurately check that the server connection still exists
before making the call. What I have not been able to verify is that the
session.isOpen() checks the service status. As the session says it is OK but
the createExecChannel() fails at service.registerChannel() because the
ConnectionService is closing.
{code}
@Override
public ChannelExec createExecChannel(String command) throws IOException {
ChannelExec channel = new ChannelExec(command);
ConnectionService service = getConnectionService();
int id = service.registerChannel(channel);
if (log.isDebugEnabled()) {
log.debug("createExecChannel({})[{}] created id={}", this, command,
id);
}
return channel;
}
{code}
By way of a qualification for {{not always}} it means that the example code
will sometimes detect that the server has gone away, however the code usually
fails as expected.
In short, what I am looking for is a way to detect that the remote server has
gone away before I call session.createChannel().
I will go back and review the example code to see where else I have made
errors. However, I believe that I found the run the command directly from
start in one of the examples. If I find that I will point it out. I would
hasten to point out that the test code ran and failed as expected on 2
different systems, so while it may be poorly coded it fails. Thank you for
taking the time to look at this report.
> SSHD does not always detect remote closure in time.
> ---------------------------------------------------
>
> Key: SSHD-720
> URL: https://issues.apache.org/jira/browse/SSHD-720
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 1.4.0
> Reporter: Claude Warren
> Priority: Minor
> Attachments: CommsTest2.java, CommsTest2a.java
>
>
> I am attempting to use a device that will close the connection if there are
> any invalid commands. The client side does not detect this condition and I
> don't see any way to check for it.
> Example code is attached
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)