Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a8ef208

Browse files
authored
Terminate connections when they reach DC limit (#443)
1 parent d7e206d commit a8ef208

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

wsnet/cache.go

+9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ func (d *DialerCache) evict() {
6565

6666
// If we're no longer signaling, the connection is pending close.
6767
evict := dialer.rtc.SignalingState() == webrtc.SignalingStateClosed
68+
69+
// HACK: since the pion package can't reuse data channel IDs we need
70+
// to terminate the connection once we approach the critical number.
71+
// We're working on adding data channel ID reuse support upstream.
72+
stats, ok := dialer.rtc.GetStats().GetConnectionStats(dialer.rtc)
73+
if ok && stats.DataChannelsRequested > 32500 {
74+
evict = true
75+
}
76+
6877
if dialer.activeConnections() == 0 && time.Since(d.atime[key]) >= d.ttl {
6978
evict = true
7079
} else {

0 commit comments

Comments
 (0)