Skip to content

Tolerate transport send errors when relaying TURN client messages#104

Open
DohanKim wants to merge 1 commit into
elixir-webrtc:masterfrom
orange-store:fix/tolerate-closed-turn-socket-master
Open

Tolerate transport send errors when relaying TURN client messages#104
DohanKim wants to merge 1 commit into
elixir-webrtc:masterfrom
orange-store:fix/tolerate-closed-turn-socket-master

Conversation

@DohanKim

Copy link
Copy Markdown

handle_ex_turn_msg/3 matches the transport send result with a bare :ok = in both the gathering-transaction and relay-candidate branches. When the underlying socket has already been closed — e.g. a late ex_turn timer/refresh message arriving for a relay candidate whose socket went away — the send returns {:error, :closed} and the whole ICEAgent crashes with a MatchError, taking the PeerConnection down with it:

** (MatchError) no match of right hand side value: {:error, :closed}
    lib/ex_ice/priv/ice_agent.ex:950: ExICE.Priv.ICEAgent.handle_ex_turn_msg/3
    lib/ex_ice/ice_agent.ex:464: ExICE.ICEAgent.handle_info/2

We hit this in production on ex_ice 0.13.0 relaying via Cloudflare TURN, inside an ex_webrtc/Membrane SFU where the agent crash cascaded into the media pipeline and ended the call for everyone.

This PR handles the error the way nearby send paths already do (e.g. the connectivity-check send path uses a case): log at debug, then drop the gathering transaction / close the relay candidate gracefully.

🤖 Generated with Claude Code

handle_ex_turn_msg matches the transport send result with a bare
':ok =' in both the gathering-transaction and relay-candidate branches.
When the underlying socket has already been closed (e.g. a late ex_turn
timer/refresh message arriving for a relay candidate whose socket went
away), the send returns {:error, :closed} and the whole ICEAgent crashes
with a MatchError, taking the PeerConnection down with it:

    ** (MatchError) no match of right hand side value: {:error, :closed}
        lib/ex_ice/priv/ice_agent.ex:950: ExICE.Priv.ICEAgent.handle_ex_turn_msg/3

Observed in production (ex_ice 0.13.0 relaying via Cloudflare TURN, in an
ex_webrtc/Membrane SFU where the agent crash cascaded into the media
pipeline).

Handle the error the way nearby send paths already do: log, then drop
the gathering transaction / close the relay candidate gracefully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant