www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: [libssh2] meaning of -37 "Failed getting banner" / "Unable to exchange encryption keys" /

Re: [libssh2] meaning of -37 "Failed getting banner" / "Unable to exchange encryption keys" /

From: Nick Rudnick <nick.rudnick_at_googlemail.com>
Date: Thu, 26 Apr 2012 00:41:58 +0200

Thank you very much... :-)

With your method, the error message is 'Resource temporarily unavailable'
(!)

Digging deeper, I found two remarkable things:

1) session->api_timeout == 0
... might be due to the interface (no session->api_timeout set??), but this
doesn't seem to lead to program interruption.

2) in session.c::_libssh2_wait_socket(), line 632 HAVE_POLL holds...

rc = poll(sockets, 1, has_timeout?ms_to_next: -1);

returns -1, which directly leads to LIBSSH2_ERROR_TIMEOUT.

Any idea??

Thanks a lot in advance, Nick

2012/4/25 TJ Saunders <tj_at_castaglia.org>

>
> > [libssh2] 0.953586 Socket: Error recving 1 bytes: 11
> > [libssh2] 0.953603 Failure Event: -37 - Failed getting banner
> > Main: TIMEOUT
>
> The "Error recving 1 bytes: 11" message comes from this code in
> src/session.c:
>
> _libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
> "Error recving %d bytes: %d", 1, errno);
>
> which means that that 11 is the errno value on your system. (On my Ubuntu
> Linux machine, errno 11 is EGAIN. Arguably, that error message could be
> made more legible using strerror(), e.g.:
>
> _libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
> "Error recving %d bytes: [%d] %s", 1, errno, strerror(errno));
>
> The -37 value is defined in the <libssh2.h> header file:
>
> #define LIBSSH2_ERROR_EAGAIN -37
>
> indicating that the calling code should try the call again. So the error
> could be transient (e.g. your socket is non-blocking, and there simply
> wasn't data to be read yet on the socket when you called). In fact, you
> see evidence of this in your second trace:
>
> > = = = = = = = = = = = = = = = = =
> > Failure Event: -37 - Failed getting banner
> > - - - - - - - - - - - - - - - - - -
> > [libssh2] 0.299932 Transport: session_startup for socket 3
> > [libssh2] 0.299979 Transport: Sending Banner: SSH-2.0-OpenSSH_5.4
> > [libssh2] 0.300057 Socket: Sent 21/21 bytes at 0x1ffb630+0
> > [libssh2] 0.300118 Socket: Error recving 1 bytes: 11
> > [libssh2] 0.300149 Failure Event: -37 - Failed getting banner
> > [libssh2] 0.307140 Socket: Recved 1 bytes banner
>
> Here we see the "-37 - Failed getting banner", but then it is followed by
> reading the bytes for the banner, one at a time:
>
> > [libssh2] 0.307161 Socket: Recved 1 bytes banner
> > [libssh2] 0.307168 Socket: Recved 1 bytes banner
> > [libssh2] 0.307174 Socket: Recved 1 bytes banner
> > [libssh2] 0.307179 Socket: Recved 1 bytes banner
> > [libssh2] 0.307184 Socket: Recved 1 bytes banner
> > [libssh2] 0.307189 Socket: Recved 1 bytes banner
> > [libssh2] 0.307195 Socket: Recved 1 bytes banner
> > [libssh2] 0.307200 Socket: Recved 1 bytes banner
> > [libssh2] 0.307205 Socket: Recved 1 bytes banner
> > [libssh2] 0.307210 Socket: Recved 1 bytes banner
> > [libssh2] 0.307215 Socket: Recved 1 bytes banner
> > [libssh2] 0.307220 Socket: Recved 1 bytes banner
> > [libssh2] 0.307226 Socket: Recved 1 bytes banner
> > [libssh2] 0.307231 Socket: Recved 1 bytes banner
> > [libssh2] 0.307236 Socket: Recved 1 bytes banner
> > [libssh2] 0.307241 Socket: Recved 1 bytes banner
> > [libssh2] 0.307246 Socket: Recved 1 bytes banner
> > [libssh2] 0.307251 Socket: Recved 1 bytes banner
> > [libssh2] 0.307257 Socket: Recved 1 bytes banner
> > [libssh2] 0.307263 Socket: Recved 1 bytes banner
> > [libssh2] 0.307273 Transport: Received Banner: SSH-2.0-OpenSSH_5.8
>
> And again here, as part of the key exchange:
>
> > [libssh2] 0.307979 Transport: Looking for packet of type: 20
> > [libssh2] 0.307988 Failure Event: -37 - Unable to exchange encryption
> keys
> > [libssh2] 0.308285 Socket: Recved 856/16384 bytes to 0x1fea5f8+0
>
> <snip>
>
> > [libssh2] 0.309464 Transport: Packet type 20 received, length=846
> > [libssh2] 0.309474 Transport: Looking for packet of type: 20
>
> So the looked-for packet of type 20 was found.
>
> Hope this helps shed some light on things,
> TJ
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> We can understand one another; but each of us is able to
> interpret himself to himself alone.
>
> -Hermann Hesse
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-04-26

the libssh2 team