From 25ae442096764560d79badd251274e70ead12063 Mon Sep 17 00:00:00 2001 From: delthas Date: Fri, 8 Apr 2022 16:48:10 +0200 Subject: Add a 15s keepalive to connections My DSL line is awful atm, I'd like to know ASAP when I'm disconnected so that I don't write paragraphs into the void. --- app.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.go b/app.go index 3b34bd8..c0f0112 100644 --- a/app.go +++ b/app.go @@ -351,6 +351,11 @@ func (app *App) tryConnect() (conn net.Conn, err error) { return } + if tcpConn, ok := conn.(*net.TCPConn); ok { + tcpConn.SetKeepAlive(true) + tcpConn.SetKeepAlivePeriod(15 * time.Second) + } + if app.cfg.TLS { host, _, _ := net.SplitHostPort(addr) // should succeed since net.Dial did. conn = tls.Client(conn, &tls.Config{ -- cgit v1.2.3