artyom-poptsov / guile-ssh

Guile-SSH is a library that provides access to the SSH protocol for GNU Guile programs.
https://memory-heap.org/~avp/projects/guile-ssh
GNU General Public License v3.0
65 stars 13 forks source link

problems reconnecting session object #25

Closed vapniks closed 3 years ago

vapniks commented 4 years ago

If I create a session object to connect to a dropbear server, and then connect it, disconnect it, and then try to reconnect again, it usually won't reconnect, but sometimes does. If I check netstat I see that the tcp connection is established, even though guile reports the session as disconnected, and authenticate-server returns 'ok, but userauth-public-key/auto! returns 'error. If I then create another session object with the same options, it connects fine every time. What's going on?

artyom-poptsov commented 4 years ago

Hello,

the problem is that on disconnect! call a Guile-SSH session frees all its resources and thus it cannot be properly reused.

But the underlying libssh session can be reused. Here's the description of ssh_disconnect procedure from the libssh 0.9.4 documentation:

Disconnect from a session (client or server). The session can then be reused to open a new session.

So in theory it's possible to reuse libssh session, but it's not implemented in Guile-SSH sessions.

I'd recommend you to make a new session and use it instead of the disconnected one.

Artyom.

vapniks commented 4 years ago

OK, thanks for the clarification