Coturn stun server returned an error with code=701

Roman picture Roman · Apr 1, 2020 · Viewed 11.5k times · Source

I have my own server with ubuntu 19.

NOTE: I need a stun/turn server for a video chat web application. It works already if both devices are in the same network.

I have successfully installed and configured coturn. I can successfully start the turnserver by running: turnserver or nohup turnserver & in the terminal.

NOTE: I have an SSH connection to my server.

I also ensured that the necessary ports are open and checked them with netstat -tulpn.

I have been also restarting coturn a few times while testing sudo service coturn restart.

I use these configurations in the turnserver.conf:

# Also tried 80
listening-port=3478
# Also tried 443
tls-listening-port=5349
listening-ip=<MY-IP4>
listening-ip=<MY-IP6>
relay-ip=<MY-IP4>
external-ip=<MY-IP4>
oauth
user=root:<password>
userdb=/var/lib/turn/turndb
no-stdout-log

This is my iceServers config in js, which I believe should work (I have done TONS of other combinations).

var pcConfig = {
  'iceServers': [
    {
      'urls': 'stun:<MY-IP4>:80'
    },
    {
      'urls': 'turn:<MY-IP4>:80',
      'credential': '<PASSWORD>',
      'username': 'root'
    }
  ]
};

I have done TONS of different stun/turn server combinations, e.g.:

  • I used google's stun servers: stun.l.google.com:19302, stun2.l.google.com:19302 etc.

  • I tried ports 3478 and 5349 (of course after restarting coturn)

  • I tried to use credentials for the stun server, but I am sure it does not need them

  • I tried to use IP6 address

I have also been doing tests live on my webproject and also here: https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

Basically the testing URL above always gives me:

Note: errors from onicecandidateerror above are not neccessarily fatal. For example an IPv6 DNS lookup may fail but relay candidates can still be gathered via IPv4.
The server stun:<MY-IP4>:80 returned an error with code=701:
STUN server address is incompatible.
The server stun:<MY-IP4>:80 returned an error with code=701:
STUN server address is incompatible.

It does not matter whether I use google's stun server or my own, the error is the same.

My webproject and the video chat WORKS great if I use the same network, but I believe stun and turn servers are not used in the same network.

Also while I updated my JS file I always deleted cache, so the new JS file was used. So that was also not an issue.

EDIT

This combination does not give an error, only:

Note: errors from onicecandidateerror above are not 
neccessarily fatal. For example an IPv6 DNS 
lookup may fail but relay candidates can still be gathered via IPv4.

Tested on https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

{
  'urls': 'stun:<MY-IP6>:80'
},
{
  'urls': 'turn:<MY-IP4>:80',
  'credential': '<PASSWORD>',
  'username': 'root'
}

I simply used IP6 for the stun and IP4 for turn. Video chat in different network still does not work, nowhere other errors to find.

EDIT:

Noticed today that https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ does not work. I had no errors on firefox. BUT you can enter some nonesense there and it will also show no errors...

EDIT:

I have also added now valid certificates:

cert=/usr/local/etc/turn.pem                                                                                    
pkey=/usr/local/etc/turn.key.pem

Seems to work. I restarted coturn and status tells me that everything is running without issues.

Video chat still does not work in different networks.

Answer

Roman picture Roman · Apr 3, 2020

Okay. I was looking at the whole thing from the wrong angle. The TURN/STUN server setup is correct.

The issue is with the client/server code. The signaling does not work.

I followed this article, but I have problems to setup the signaling service. I think this must be asked in a new question.