Create PeerConnection exception: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer

7.3k Views Asked by At

I am using appRTC to make demo app. I have setup following things successfully but got stack with JSON format that return in response of Turn-server API.

  • Use SSL for secure connect to make it work on Google Chrome (Done)
  • Implement custom WebSockets (Done)
  • Develop custom API for TurnServer (Done)

I am getting following error in console log.

Create PeerConnection exception: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer

Failed to start signaling: Cannot read property 'addStream' of null

I have tried following responses as ice server object

Current object:

{"iceServers":[{"urls":["stun:stun.l.google.com:19302"]},{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}],"lifetimeDuration":"86400s","blockStatus":"NOT_BLOCKED","iceTransportPolicy":"all"}

Have also tried:

[{"urls":["stun:stun.l.google.com:19302"]},{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}]

and also tried this one:

[{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}]
1

There are 1 best solutions below

9
On

You have a typo here: [{"urls":["stun:stun.l.google.com:19302"} trying to close urls without closing the array. This should be [{"urls":["stun:stun.l.google.com:19302"]} This doesn't result in an error about malformed RTCIceServer though.

Based on your comment it seems to be a result of calling new RTCPeerConnection({"iceServers":[{}]}) -- an empty object is not a valid RTCIceServer.

I would also recommend not passing "lifetimeDuration":"86400s","blockStatus":"NOT_BLOCKED" to the RTCPeerConnection as it doesn't know about these.