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

Terminate connections when they reach DC limit #443

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions wsnet/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ func (d *DialerCache) evict() {

// If we're no longer signaling, the connection is pending close.
evict := dialer.rtc.SignalingState() == webrtc.SignalingStateClosed

// HACK: since the pion package can't reuse data channel IDs we need
// to terminate the connection once we approach the critical number.
// We're working on adding data channel ID reuse support upstream.
stats, ok := dialer.rtc.GetStats().GetConnectionStats(dialer.rtc)
if ok && stats.DataChannelsRequested > 32500 {
evict = true
}

if dialer.activeConnections() == 0 && time.Since(d.atime[key]) >= d.ttl {
evict = true
} else {
Expand Down