From dad5ab89a58be8c755ea6ef87b4bb6dbaefb5589 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 3 May 2020 18:39:16 +1000 Subject: [PATCH] Limit the write buffer to work around a webrtc datachannel issue https://github.com/pion/datachannel/issues/59. Fixes https://github.com/anacrolix/torrent/issues/402. --- peerconn.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/peerconn.go b/peerconn.go index 0e267a78..3e18544b 100644 --- a/peerconn.go +++ b/peerconn.go @@ -601,7 +601,9 @@ func (cn *PeerConn) writer(keepAliveTimeout time.Duration) { cn.wroteMsg(&msg) cn.writeBuffer.Write(msg.MustMarshalBinary()) torrent.Add(fmt.Sprintf("messages filled of type %s", msg.Type.String()), 1) - return cn.writeBuffer.Len() < 1<<16 // 64KiB + // 64KiB, but temporarily less to work around an issue with WebRTC. TODO: Update + // when https://github.com/pion/datachannel/issues/59 is fixed. + return cn.writeBuffer.Len() < 1<<15 }) } if cn.writeBuffer.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout { -- 2.48.1