From 3c7b32056b93622b01d2aa55537287693ba0eec1 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 14 Feb 2021 16:24:22 +0100 Subject: [PATCH] Reduce writer timeout, increase amount of buffering. If the writer gets congested, the whole group might be delayed. Better to drop the slow client in that case. --- rtpconn/webclient.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 1281dba..f532108 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -746,7 +746,7 @@ func StartClient(conn *websocket.Conn) (err error) { defer close(c.done) - c.writeCh = make(chan interface{}, 25) + c.writeCh = make(chan interface{}, 100) c.writerDone = make(chan struct{}) go clientWriter(conn, c.writeCh, c.writerDone) defer func() { @@ -1497,7 +1497,8 @@ func clientWriter(conn *websocket.Conn, ch <-chan interface{}, done chan<- struc break } err := conn.SetWriteDeadline( - time.Now().Add(2 * time.Second)) + time.Now().Add(500 * time.Millisecond), + ) if err != nil { return }