reverse_ssh icon indicating copy to clipboard operation
reverse_ssh copied to clipboard

Client disconnects after 240s if server timeout is set to 300s

Open neben opened this issue 11 months ago • 3 comments

I've set the server timeout to 300 seconds (--timeout 300), but now I'm seeing the clients always disconnect after 240s. This looks like the initial client timeout. IIUC the server should update the client timeout to twice the server timeout. Is this timeout info sent with the server keep-alive packet? And is the keep-alive packet sent timeout seconds after connection establishment? This then would explain that if I set the server timeout (300s) to a value higher than the initial timeout (240s), the client times out before ever receiving the timeout update.

If that is the case, wouldn't it make sense to transmit the server timeout value to the client upon connection establishment?

neben avatar Jan 22 '25 10:01 neben

Hm, this is a bit odd as the client does actually update its own timeout based on the servers timeout setting.

https://github.com/NHAS/reverse_ssh/blob/663d5d736037e760a940401062d0c750ea7bc87b/internal/client/client.go#L396

				case "[email protected]":
					req.Reply(false, nil)
					timeout, err := strconv.Atoi(string(req.Payload))
					if err != nil {
						continue
					}

					realConn.Timeout = time.Duration(timeout*2) * time.Second

NHAS avatar Jan 24 '25 13:01 NHAS

If I set the timeout to 120, everything works fine. Is there anything I can do to help debug this?

neben avatar Jan 27 '25 12:01 neben

Hm, other than ensuring that the client is getting the right timeout value via the keepalive I cant really think of much.

NHAS avatar Jan 28 '25 06:01 NHAS