Skip to content

parseIceServers returns undefined turnServer and stunServer #385

@nandito

Description

@nandito

The RTCIceGatherer's ice server config has undefined value for each key:

https://github.com/shinyoshiaki/werift-webrtc/blob/develop/packages/webrtc/src/peerConnection.ts#L485

{
  stunServer: undefined,
  turnServer: undefined,
  turnUsername: undefined,
  turnPassword: undefined
}

I think this happens as the parseIceServers util (https://github.com/shinyoshiaki/werift-webrtc/blob/develop/packages/webrtc/src/peerConnection.ts#L485) tries to use the .includes("turn:") and .includes("stun:") on arrays.

So we have this function call in the utils.ts:

const turnServer = url2Address(
  iceServers.find(({ urls }) => urls.includes("turn:"))?.urls.slice(5),
);

where the iceServers looks like this:

 [
  {
    url: 'turn:turn-myturnserver.com:443',
    urls: ['turn:turn-myturnserver.com:443'],
    username: 'username',
    credential: 'creds='
  }
]

If we inspect the url2Address parameter:

iceServers.find(({urls}) => urls.includes("turn:"))

We can see that it runs the includes() fn on an array, not on a string.

['turn:turn-myturnserver.com:443'].includes("turn:")

This is always false, therefore the find() won't find any turn: in this case.

I assume a nested find() function would fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions