From 573532262729f497b4148f4caa69b2275b9f7bb2 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 4 Jan 2021 18:02:50 +0100 Subject: [PATCH] Add websocket handshake timeout. --- webserver/webserver.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webserver/webserver.go b/webserver/webserver.go index 1fc845a..c30fcda 100644 --- a/webserver/webserver.go +++ b/webserver/webserver.go @@ -430,10 +430,12 @@ func statsHandler(w http.ResponseWriter, r *http.Request, dataDir string) { fmt.Fprintf(w, "\n") } -var upgrader websocket.Upgrader +var wsUpgrader = websocket.Upgrader { + HandshakeTimeout: 30 * time.Second, +} func wsHandler(w http.ResponseWriter, r *http.Request) { - conn, err := upgrader.Upgrade(w, r, nil) + conn, err := wsUpgrader.Upgrade(w, r, nil) if err != nil { log.Printf("Websocket upgrade: %v", err) return