Skip to content

fix(desktop): retry host SFU connect instead of failing on first ICE miss#24

Merged
ralyodio merged 1 commit into
masterfrom
fix/host-connect-retry
Jun 23, 2026
Merged

fix(desktop): retry host SFU connect instead of failing on first ICE miss#24
ralyodio merged 1 commit into
masterfrom
fix/host-connect-retry

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Problem

Users on a flaky/multi-homed host kept seeing "Streaming error: could not establish pc connection" even on 0.8.2. The SFU logs show the publisher's first ICE negotiation fails, but the very next attempt connects fine via the TURN relay (participant active, udp relay). PR #21 suppressed the toast for livekit's own post-connection reconnects, but the initial room.connect() / mic publish still went straight to the catch and surfaced a fatal toast on that first miss.

Fix

startHosting now retries room.connect() up to 3× with backoff, disconnecting between attempts. Those intentional disconnects are suppressed (a connecting guard) so they don't flash the "Disconnected" toast. The mic publish is also made non-fatal — a transient publisher-PC hiccup no longer aborts hosting (the screen share publishes separately and livekit recovers). Only genuine exhaustion of all retries surfaces an error.

This is the "can't you just retry?" fix: it turns the common first-attempt-fails / second-attempt-works case into a silent success.

Test

Added two cases (fake timers): connects on a later attempt with no error toast (isHosting true, error null, 2 connect calls, 1 disconnect); and surfaces the error only after all 3 attempts fail. Existing 3 pass. 5/5; full monorepo lint passes.

Underlying cause is still the host's dead enp2s0 NIC — this makes the app resilient to it, but sudo ip link set enp2s0 down + Force-relay remain the root fix.
Ships in the Electron app (desktop release).

🤖 Generated with Claude Code

…miss

On a flaky multi-homed host the publisher's first ICE negotiation often
fails ("could not establish pc connection") even though a retry immediately
lands on a working candidate pair — the SFU logs show exactly this (first
attempt dropped, second "participant active" via udp relay). Previously that
first failure went straight to the catch and surfaced a fatal error toast,
even though reconnecting would have worked.

startHosting now retries room.connect() up to 3x with backoff, disconnecting
between attempts (those intentional drops are suppressed so they don't flash
the "Disconnected" toast). The mic publish is also made non-fatal — a
transient publisher-PC hiccup no longer aborts hosting. Only a genuine
exhaustion of all retries surfaces the error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio ralyodio merged commit e29f59c into master Jun 23, 2026
11 checks passed
@ralyodio ralyodio deleted the fix/host-connect-retry branch June 23, 2026 07:48
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

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