Repository navigation
Forward signal/close to legacy clients - #39
Open
masnwilliams wants to merge 1 commit into
Open
masnwilliams wants to merge 1 commit into
masnwilliams wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the server destroys a viewer's WebRTC peer while its websocket stays open (for example, ICE goes
disconnectedafter a phone locks or backgrounds the page for longer thandisconnectedTimeout), the session sendssignal/close. The legacy (v2) protocol proxy has no translation for it, so it logscouldn't rewrite text message error="unknown event type: signal/close"and drops it. The legacy client never learns the stream is gone and keeps showing a black video element over an open websocket.Changes
signal/closeto the legacy event set and forward it to the client as{"event":"signal/close"}.Not included
Raising
disconnectedTimeout(4s) ininternal/webrtc/manager.gowould let short app switches keep the same peer, but it is an upstream constant that applies to every viewer: a dead peer keeps its encoder pipelines and bandwidth for the extra seconds before it is destroyed. Left as a separate decision.Testing
go test ./internal/http/legacy/ -run SignalClose: passes. The new test fails against the previouswstoclient.gowithunknown event type: signal/close.go vet ./internal/http/legacy/clean.Note
Low Risk
Narrow protocol-bridge change with a unit test; no auth or data-path changes.
Overview
Fixes a gap where the server emits
signal/closeafter tearing down a viewer's WebRTC peer (e.g. ICE disconnected past timeout) but the legacy v2 websocket proxy treated it as unknown and dropped it, leaving clients with a black video while the socket stayed open.Adds
SIGNAL_CLOSEto the legacy event constants and awsToClientbranch that forwards it as{"event":"signal/close"}. Clients that do not handle the event are unchanged; clients that do can reconnect.Includes
TestWsToClientForwardsSignalCloseto assert the legacy client websocket receives the forwarded event.Reviewed by Cursor Bugbot for commit f82810f. Bugbot is set up for automated code reviews on this repo. Configure here.