-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for keep-alive messages #12
Comments
👍 |
Here's how we do it in ssh-chat: https://github.com/shazow/ssh-chat/blob/ee8d60ec00526be52d2acadfb088bad96790640d/sshd/terminal.go#L87-L104 |
That looks almost identical to how I've done it in the past as well... Though my personal preference is to do it at the connection level so you don't need separate keep-alives for every channel. |
you can use TCP keepalives for this relatively easily err = ssh.ListenAndServe(
":22",
nil,
ssh.WrapConn(func(s ssh.Context, conn net.Conn) net.Conn {
conn.(*net.TCPConn).SetKeepAlive(true)
conn.(*net.TCPConn).SetKeepAlivePeriod(time.Second * 100)
return conn
}),
) |
that's pretty cool. i think people avoid tcp keepalives though because of proxies but ymmv |
hmm this didn't work for me
Somehow even this didn't prevent the connection from being terminated. I checked that the client was receiving the requests, and it was. |
Pretty self explanatory. Just sending keepalive@whatever as a request which needs a reply is enough to get both sides to send a little data to keep the connection living. openssh uses keepalive@openssh (or something very similar) this way.
The text was updated successfully, but these errors were encountered: