Skip to content

Proxy: Reclaim closed and idle WebRTC sessions - #4795

Open
xhy279 wants to merge 1 commit into
ossrs:developfrom
xhy279:bugfix/proxy-rtc-session-cleanup
Open

xhy279 wants to merge 1 commit into
ossrs:developfrom
xhy279:bugfix/proxy-rtc-session-cleanup

Conversation

@xhy279

@xhy279 xhy279 commented Nov 2, 2026

Copy link
Copy Markdown

Repeated WebRTC negotiations and disconnects retain entries in the Proxy's username/address caches, connected UDP sockets and blocked backend-reader goroutines. WHIP/WHEP DELETE currently forwards the request without releasing the local session, and a 204 response is rejected.

This change closes sessions on successful DELETE, I/O failure, shutdown or 120 seconds without inbound client traffic, with a 5-second sweep. It evicts the associated indexes, bounds address-cache growth during NAT rebinding, and preserves a replacement session that reuses an address or stream key. DELETE uses the exact resource URL and the original Origin; outgoing video does not keep a departed client alive. Media lifetime is independent of the completed SDP request. Redis metadata retains its existing TTL; the memory LB removes only matching entries.

Validation:

  • go test -race ./...
  • go vet ./internal/proxy ./internal/lb ./internal/sync
  • go test -race ./internal/proxy -run '^TestRTCSession' -count=20

Regression tests cover 500 real UDP connections per churn run, idle versus active sessions, exact DELETE with HTTP 204, request cancellation, address rebinding/reuse, I/O failure, shutdown and concurrent expiry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant