From 54ee56128741051ef1262d4397083accb0d8086c Mon Sep 17 00:00:00 2001 From: Alvaro Viebrantz Date: Wed, 24 Nov 2021 17:44:23 -0400 Subject: [PATCH] fix: set write deadline before writing messages --- wsproxy/websocket_proxy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wsproxy/websocket_proxy.go b/wsproxy/websocket_proxy.go index 7092162..009b724 100644 --- a/wsproxy/websocket_proxy.go +++ b/wsproxy/websocket_proxy.go @@ -294,6 +294,9 @@ func (p *Proxy) proxy(w http.ResponseWriter, r *http.Request) { } for scanner.Scan() { + if p.pingWait > 0 { + conn.SetWriteDeadline(time.Now().Add(p.pingWait)) + } if len(scanner.Bytes()) == 0 { p.logger.Warnln("[write] empty scan", scanner.Err()) continue