Subject: Re: libssh2 hangs in channel_close()

Re: libssh2 hangs in channel_close()

From: Simon Josefsson <>
Date: Tue, 13 Apr 2010 10:06:29 +0200

Daniel Stenberg <> writes:

> Hi
> The problem with the self test is the code in channel_close() that
> unconditionally waits for the remote EOF to arrive. Quite clearly it
> is simply not coming here, and thus libssh2 hangs there waiting for
> it.
> This was introduced by Peter in commit
> 16af813b812aca09c73045288040ddf1a03a2b86:
> Send and receive channel EOF before sending SSH_MSG_CHANNEL_CLOSE
> Sending SSH_MSG_CHANNEL_CLOSE without channel EOF is explicitly allowed
> in RFC 4254, but some non-conforming servers will hang or time out when
> the channel is closed before EOF.
> Other common clients send and receive EOF before closing, there are no
> drawbacks, and some servers need it to work correctly.
> Is there really anything we can do about this? I mean, if we're about
> to close the channel, we can't sit and waiting for an EOF that might
> not come!

If OpenSSH server doesn't send EOF, I think libssh2 need to do something
so that it interops with it. I'm using OpenSSH 5.3p1 from debian, which
is fairly modern.

Maybe we can SEND the EOF but not wait for one?

It seems like a bug in these other servers to me, if the RFC permits our
old behaviour. Peter, which servers are these? Naming them, with
version numbers, is useful in discussions like this.

Received on 2010-04-13