Skip to content

WebRTC peer connection never establishes on Linux x64; Rust FFI binary fixes it #642

@nathan-polyglossia

Description

@nathan-polyglossia

Select which package(s) are affected

@livekit/rtc-node

Describe the bug

@livekit/rtc-node can't establish WebRTC peer connections on my Linux x64 machine. WebSocket signaling works fine, but the native layer never opens any UDP or TCP sockets for ICE. The connection just hangs.

The Python SDK (livekit v1.1.3) connects instantly on the same machine to the same server.

I found that copying the native binary from @livekit/rtc-ffi-bindings-linux-x64-gnu v0.12.52 over the one in @livekit/rtc-node-linux-x64-gnu fixes it immediately. The existing v0.13.24 JS wrapper code works with the new binary, no changes needed. At least for my needs of publishing audio-only to livekit.

What happens

  1. WebSocket signaling connects. LiveKit server logs show "starting RTC session" with the participant.
  2. The native layer never opens any UDP or TCP sockets for WebRTC (verified with lsof -i).
  3. After about 15 seconds, the server logs "removing participant without connection" with connectionType: "unknown".
  4. room.connect() never resolves or rejects.

Reproduction

const { Room, AudioSource, LocalAudioTrack, TrackPublishOptions } = require('@livekit/rtc-node');
const { AccessToken } = require('livekit-server-sdk');

async function test() {
  const token = new AccessToken('devkey', 'secret', { identity: 'test-pub' });
  token.addGrant({ roomJoin: true, room: 'test-room', canPublish: true, canSubscribe: false });
  const jwt = await token.toJwt();

  const room = new Room();
  const src = new AudioSource(16000, 1);
  const track = LocalAudioTrack.createAudioTrack('audio', src);

  // Hangs here. Never resolves or rejects.
  await room.connect('ws://localhost:7880', jwt, { autoSubscribe: false, dynacast: false });
  await room.localParticipant.publishTrack(track, new TrackPublishOptions());
  await room.disconnect();
}
test();

Logs

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 31.74 GB / 62.74 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 22.12.0 - /home/nehresman/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 3.7.0 - /home/nehresman/.nvm/versions/node/v22.12.0/bin/yarn
    npm: 10.9.0 - /home/nehresman/.nvm/versions/node/v22.12.0/bin/npm
  npmPackages:
    @livekit/rtc-node: 0.13.24 => 0.13.24 
    livekit-server-sdk: ^2.15.0 => 2.15.0

LiveKit server version

latest self hosted version

Severity

serious, but I can work around it

Additional Information

What I tested

Approach Result
@livekit/rtc-node 0.13.16 through 0.13.24 Hangs, no peer connection
@livekit/rtc-node 1.0.0-alpha.1 Hangs, no peer connection
Python SDK livekit v1.1.3 (same machine, same server) Connects instantly
Swap native binary to @livekit/rtc-ffi-bindings-linux-x64-gnu v0.12.52 Connects instantly
Docker vs native LiveKit server Both fail with the Node SDK
node_ip: 127.0.0.1 / 192.168.x.x / enable_loopback_candidate: true No difference
CUDA_VISIBLE_DEVICES="" (disable GPU) No difference

Root cause

The NAPI/C++ native binary (37MB) shipped with @livekit/rtc-node doesn't establish peer connections on this platform. The Rust FFI binary (25MB) from @livekit/rtc-ffi-bindings v0.12.52 works correctly. It uses the same backend as the Python SDK, which is why the Python SDK works.

I confirmed this by copying the Rust FFI .node file over the NAPI one in node_modules/@livekit/rtc-node-linux-x64-gnu/. The existing v0.13.24 JS wrapper code works perfectly with the new binary.

Question

I see PR #599 ("Update FFI and remove napi") on the main branch, which switches to the Rust FFI backend. Is there a planned release timeline for this? I'm building a production audio publishing pipeline on @livekit/rtc-node and was really hoping to use your SDK for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions