1

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"}]
Community
  • 1
  • 1
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50

1 Answers1

2

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.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
  • Sorry that typo was accrued when I paste my response here because I overwrite some values. I have updated my answer, Please have a look – Muhammad Hassaan Jul 31 '18 at 09:26
  • Here is TURNSERVER API URL, I am using to get response. You can see real response from this [link](https://domaintools.ltd/turnserver-api/) – Muhammad Hassaan Jul 31 '18 at 09:27
  • I have live the demo URL that I am testing, you can test this by your self, might be I am wrong somewhere. – Muhammad Hassaan Jul 31 '18 at 09:28
  • you are calling "new RTCPeerConnection({"iceServers":[{}]})" somehow even though the http response looks correct. And an empty object is not a valid ice server – Philipp Hancke Jul 31 '18 at 09:35
  • yes that's the problem. iceServers will not filled automatically by TURN HTTP request? Should I hard-code them? – Muhammad Hassaan Jul 31 '18 at 09:41
  • hardcoding turn credentials is a very bad idea. It looks like your format is different from what apprtc expects, see the line in the source code that says ``` var turnServers = createIceServers(turnServerResponse.uris, turnServerResponse.username, turnServerResponse.password); ``` This looks like there is a mismatch between your apprtc version and the appr.tc one – Philipp Hancke Jul 31 '18 at 09:53
  • Yes, I have notice the code available at GitHub repo is quit old. My `apprtc.debug.js` has 2000 lines of code but appr.tc have 5000+ lines of code at same file. – Muhammad Hassaan Jul 31 '18 at 10:04
  • Can you please help me to sort the issue. I am stack with this from 3 days – Muhammad Hassaan Jul 31 '18 at 10:06
  • I have hard-coded the values of IceServer config for testing purpose. But still getting same error + `Cannot create RTCPeerConnection; WebRTC is not supported by this browser.` – Muhammad Hassaan Jul 31 '18 at 12:45