Skip to content

add connection test cli tool - #1324

Open
chenosaurus wants to merge 1 commit into
mainfrom
dc/connection_test
Open

add connection test cli tool#1324
chenosaurus wants to merge 1 commit into
mainfrom
dc/connection_test

Conversation

@chenosaurus

Copy link
Copy Markdown
Contributor
  • Add a simple CLI tool to test connection to LK Cloud & report the method

@chenosaurus
chenosaurus requested a review from ladvoc as a code owner August 10, 2026 20:27

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +47 to +53
let stats = match room.get_stats().await {
Ok(stats) => stats,
Err(error) => {
eprintln!("Connected to LiveKit, but could not inspect the connection: {error}");
return ExitCode::FAILURE;
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Connection test reports failure because it inspects the connection before it is established

The connection details are requested (room.get_stats() at examples/connection_test/src/main.rs:47) immediately after joining, before the media path has finished being negotiated, so the tool usually prints that no connection could be found and exits with an error.
Impact: Users running the tool typically get "No selected WebRTC candidate pair was found" and a failure exit code instead of the connection report.

Why no selected candidate pair exists yet

Room::connect (livekit/src/room/mod.rs:566) resolves as soon as RtcEngine::connect returns, which only completes the signaling join and spawns session tasks (livekit/src/rtc_engine/rtc_session.rs:695-710). It does not await ICE/DTLS establishment — wait_pc_connection is only used on reconnect paths (livekit/src/rtc_engine/mod.rs:473, livekit/src/rtc_engine/mod.rs:1077).

As a result, at the moment get_stats() runs, neither transport has a selected_candidate_pair_id, so selected_path returns None for both publisher and subscriber and the [] branch (examples/connection_test/src/main.rs:65-68) exits with ExitCode::FAILURE. Additionally, with auto_subscribe = false and no published tracks, connectivity may take even longer or the publisher PC may never negotiate.

A fix would be to wait for RoomEvent::Connected/ConnectionState::Connected from the event receiver (currently discarded as _events) and/or poll get_stats() with a bounded retry/timeout until a selected pair appears.

Prompt for agents
The connection_test CLI calls room.get_stats() immediately after Room::connect returns. Room::connect only completes the signaling join; it does not wait for the peer connections to reach the connected state (wait_pc_connection is only used on reconnect paths in livekit/src/rtc_engine/mod.rs). Consequently the transport stats have no selected_candidate_pair_id yet, selected_path() returns None for both publisher and subscriber, and the tool exits with FAILURE reporting no candidate pair. Consider consuming the RoomEvent receiver (currently bound to `_events`) to wait for the Connected/ConnectionStateChanged event, and/or polling get_stats() on an interval with an overall timeout until a selected candidate pair is present before reporting.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +1 to +5
[package]
name = "connection_test"
version = "0.1.0"
edition = "2021"
publish = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Pull request is missing the required changeset file

No changeset entry was added under /.changeset for this change, which the repository's contribution rules require for every pull request.
Impact: Release notes/version bumping tooling has no record of this change.

Rule reference

AGENTS.md ("Documenting changes") states: "Every PR needs a changeset" and "Changeset must list any crates which need to be bumped stemming from the change". Existing entries live in /.changeset (e.g. .changeset/fix-publisher-renegotiation-deadlock.md). This PR adds examples/connection_test but no changeset file.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

path = "src/main.rs"

[dependencies]
clap = { version = "4.5", features = ["derive"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: livekit, clap, and tokio are workspace deps, set workspace = true rather than hardcoding version or path.

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.

2 participants