On Jan 29, 2021, at 11:27 AM, Adriano Donninelli <
realvi...@gmail.com> wrote:
> Hey Ron, thanks for the quick reply.
>
>> Enabling client keepalives should usually help with that, though, as long as they are sent often enough to not all the firewall to think the connection is gone. Setting it to 60 seconds SHOULD work here.
>
> I enabled the Client Keep alive (on server sshd_config) as you suggested but the problem persists. (Tried both 60 seconds and 10 seconds)
Sorry, I meant enabling what OpenSSH calls ServerKeepAlive on the AsyncSSH client, which is what you were already doing. It’s interesting that it doesn’t seem to help to enable keepallives on _either_ the client or the server, though!
> If you don’t enable client keepalives, how long can you generally leave a connection idle in your environment without seeing a “Connection lost”?
> It seems to be between 5 and 10 minutes.
>
>> Is there any correlation between the total time the connection is open and when you see the “Connection lost”?
Ok - that in the right ballpark for what I’ve seen when firewalls drop idle connections, but the connection shouldn’t be considered idle for that long once keepalives are turned on, either on the client or on the server.
> I think there’s not, I have been using the script for hours by using it constantly, it always loses the connection once I leave it in idle for a while.
>
> I want to add that a normal bash `ssh` command to the server (from terminal) left in idle for the same (and >) period of time does not result in any kind of connection lost / reset. I do not have any Keep alive config on client ssh_config file.
If you have the keepalive_interval and keepalive_count_max set on the AsyncSSH outbound client connection, that should be the equivalent of specifying the ServerAliveInterval and ServerAliveCountMax in the client SSH config file. So, not having it there should be fine.
> Do you have any further suggestion to test out?
It’s very curious that you don’t see the problem from an OpenSSH client connection. With that, was the ClientAliveInterval still set on the server? Were you running that on the same machine as you were running AsyncSSH on when you saw the problem, and connecting to the same server?
One thing you mentioned was that you wanted to run the AsyncSSH client “in the background”. How exactly are you launching that? It shouldn’t be a problem, but I just want to make sure that the process isn’t getting suspended or blocking on something else that prevents it from doing I/O on the SSH connection.
If you enable debug logging on AsyncSSH, do you see log messages about the keepalives? Also, what do the messages look like around the point where you see the connection lost error?