SciDev
SciDev

Reputation: 159

WebRTC is failing to connect after ice candidates have been added

I am making a local network chat app in JavaScript, and I am able to connect between two tabs on any single computer, but when I try to connect two computers (on the same wifi network) it fails.

What works: Two tabs on the same computer (even if different browser, ex. chrome tab<->firefox tab).

What doesn't work: Two different computers (ex. laptop<->desktop), even on same network (if one of the devices is the host of the page).

I have tried to get information from chrome://webrtc-internals/, and this seems to be the only major difference, (when it works, the numbers separated by slashes match). (this is the ice candidate grid for the failing case vv)

shows STUN requests not being replied to

Here is logs containing exchanged information between clients during failure:

enter image description here

Here are the STUN/TURN servers I'm using (in case that's the issue):

const RTC_CONFIG:RTCConfiguration = {
    iceServers:[
        {
            urls: ["turn:turn.anyfirewall.com:443?transport=tcp"],
            credential: "webrtc",
            username: "webrtc"
        },
        {
            urls: ["turn:192.158.29.39:3478?transport=tcp"],
            credential: "JZEOEt2V3Qb0y27GRntt2u2PAYA=",
            username: "28224511:1379330808"
        },
        {
            urls: [
                "stun:stun.l.google.com:19302",
                "stun:stun1.l.google.com:19302",
                "stun:stun2.l.google.com:19302",
                "stun:stun3.l.google.com:19302",
                "stun:stun4.l.google.com:19302",
            ]
        },
    ]
};

EDIT (more information):

The code continues to fail the same way if the TURN servers, STUN servers, or both are removed.

Here's what it looks like when I connect two tabs: enter image description here

Here's what it looks like when I connect two computers on same WiFi network (failure): enter image description here

EDIT 2 (testing progress):

After setting up a test server with https (and wss for signaling), the LAN connections remain non-functional, while different-network connections work (eg. desktop<->laptop in same room doesn't work, laptop<->phone on cell network does work.)

Upvotes: 4

Views: 3018

Answers (2)

SciDev
SciDev

Reputation: 159

The problem appears to be about who is connecting with who, and can be solved by making the page host server be a different device than either of the connecting devices.

WebRTC does not seem to like it if the page host is the same device as one of the connection peers.

For clarity, here is what happens when devices in different contexts connect:

Network 1 devices:
 host (webpage host)
 localA
 localB
Network 2 devices:
 remoteA
 remoteB

Connections:
host    <> localA  [fails]
localA  <> localB  [succeeds]
remoteA <> remoteB [succeeds]

Upvotes: 1

The KNVB
The KNVB

Reputation: 3844

Because the client and server are not on the same machine, when you access the media from a browser, for security reasons you must install an SSL certificate on your server.

Upvotes: 0

Related Questions