coturn / coturn

coturn TURN server project
Other
11.43k stars 2.03k forks source link

Cannot bind local socket to addr: Cannot assign requested address #311

Closed RamyaAshika closed 5 years ago

RamyaAshika commented 5 years ago

I have tried with coturn configuration with my local system using my local IP address. It worked. But now, I'm trying to configure this using my public IP. Is it possible? and I'm doing this using Cygwin, can i able to configure this in my system with my public IP address?

misi commented 5 years ago

It should work. (Un)Fortunately I don't have Cygwin only linux. (Cygwin is not recommended for production AFAIK) Try it on debian linux and I could help more..

misi commented 5 years ago

I miss your IP and logs.. It should work with any public global ipv4 address and IPv6 address too..

RamyaAshika commented 5 years ago

Ok FIne. Before that, I want to clarify this doubt.See my local ip address xxx.xxx.xx something like this and these are the steps I followed STEP 1: $ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz $ tar xvfz libevent-2.0.21-stable.tar.gz $ cd libevent-2.0.21-stable $ ./configure $ make $ make install Completed

STEP 2: We assume that you are installing the Coturn from the sources.Downloaded the latest version

$ tar xvfz turnserver-<...>.tar.gz $ ./configure $ make $ make install

STEP 3: Add the long-term TURN users with the turnadmin utility. For example, this command adds user ninefinger with password youhavetoberealistic, realm north.gov, to the default sqlite database:

$ sudo turnadmin -a -u ninefingers -r north.gov -p youhavetoberealistic

STEP 4: For example, this command adds the admin user bayaz with password magi:

$ sudo bin/turnadmin -A -u bayaz -p magi

STEP 5: From this link I have changed my turnserver.conf and turnuserdb.conf https://www.webrtc-experiment.com/docs/TURN-server-installation-guide.html#windows

Finally I ran with this command turnserver -L -a -f -r

@misi

screenshot 703

RamyaAshika commented 5 years ago

I have done these steps for my local my address. this is the result I got it and I dunno whether its working or not but its not throwing any error and in my firewall its showing like this screenshot 704

Whether it works?? @misi

RamyaAshika commented 5 years ago

But the main thing for me is I'm having my public ip address from there people will access my application. In that I want to use this. so obviously I need to use my public address instead of this local ip address. In that what my doubt is can I able to configure for my public ip address from my internal system/local system. @misi

misi commented 5 years ago

Run it with: turnserver -L x.x.x.x -a -f -r yourdomain.com

misi commented 5 years ago

If your pc not behind nat then x.x.x.x and y.y.y.y are the same.

RamyaAshika commented 5 years ago

ooh k But I didn't get this point

  1. If you behind nat then use -X y.y.y.y with your global IP y.y.y.y and set in your NAT the port forwarding to all TURN/STUN and RTP/RTCP ports.

Whether this is what you're saying? When running the final command for my public IP address from my local system. Instead of this command, turnserver -L -a -f -r Do I need to run this command? turnserver -X -a -f -r @misi

misi commented 5 years ago

The realm/domain is missing only. e.g. example.org turnserver -X <public_ip_address> -a -f -r example.org

RamyaAshika commented 5 years ago

Omg. This is what I'm getting. I have changed my config file like this

listening-port=3478 tls-listening-port=5349 alt-listening-port=3479 alt-tls-listening-port=5350 listening-ip=xxx.xxx.xx.xxx listening-ip=xxx.xxx.xx.xxx relay-ip=xxx.xxx.xx.xxx min-port=49152 max-port=65535 verbose fingerprint

use-auth-secret

static-auth-secret

userdb=/etc/turnuserdb.conf realm=xxx.xxx.xx.xxx cert=/etc/ssl/certificate.pem pkey=/etc/ssl/private.key dh-file=/etc/turn/dhparam.pem no-stdout-log log-file=/var/log/turn/turn.log lt-cred-mech user=iCore:iCore@123

no-sslv3 no-tlsv1

and I ran this command turnserver -X -a -f -r example.org

0: Trying to bind fd 40 to <192.168.42.172:3478>: errno=125 Cannot bind local socket to addr: Cannot assign requested address 0: Cannot bind DTLS/UDP listener socket to addr 192.168.42.172:3478 0: Trying to bind DTLS/UDP listener socket to addr 192.168.42.172:3478, again... bind: Cannot assign requested address

@misi

RamyaAshika commented 5 years ago

Where is the logs will be there? If you need I may send you @misi

misi commented 5 years ago

IP Make sure your ipv4 address is 192.168.42.172 cmd ipconfig /all

if your global address is y.y.y.y

config

listening-port=3478
tls-listening-port=5349
alt-listening-port=3479
alt-tls-listening-port=5350
listening-ip=192.168.42.172
relay-ip=192.168.42.172
external-ip=y.y.y.y
min-port=49152
max-port=65535
verbose
fingerprint
#use-auth-secret
#static-auth-secret
userdb=/etc/turnuserdb.conf
realm=example.org
cert=/etc/ssl/certificate.pem
pkey=/etc/ssl/private.key
dh-file=/etc/turn/dhparam.pem
no-stdout-log
log-file=/var/log/turn/turn.log
lt-cred-mech
user=iCore:iCore@123

no-sslv3
no-tlsv1

Run Run turnserver without any parameter

turnserver

RamyaAshika commented 5 years ago

Ya I have checked in my global ip address through Putty but I don't see any ip address like this 192.168.42.172 and on my local my ip address also there is no ip address like this. @misi

RamyaAshika commented 5 years ago

Whether you got any idea @misi

misi commented 5 years ago

Replace 192.168.42.172 with your local ip address...

RamyaAshika commented 5 years ago

This is how I have given

listening-port=3478 tls-listening-port=5349 alt-listening-port=3479 alt-tls-listening-port=5350 listening-ip=localipaddress relay-ip=localipaddress external-ip=online/publicipaddress min-port=49152 max-port=65535 verbose fingerprint

use-auth-secret

static-auth-secret

userdb=/etc/turnuserdb.conf realm=icoretek.com cert=/etc/ssl/certificate.pem pkey=/etc/ssl/private.key dh-file=/etc/turn/dhparam.pem no-stdout-log log-file=/var/log/turn/turn.log lt-cred-mech user=iCore:iCore@123

no-sslv3 no-tlsv1

and ran the command $ turnserver -L localipaddress -a -f -r icoretek.com

now its not showing any error whether its connected? @misi

RamyaAshika commented 5 years ago

Please Can I know which [turn_server_ip_address] we need to add here in pc_config variable? var pc_config = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}, {"url":"turn:my_username@", "credential":"my_password"}]}; pc_new = new webkitRTCPeerConnection(pc_config);

@misi

RamyaAshika commented 5 years ago

Hey Hi Misi, Now I'm currently running this project on Centos Linux. I have followed all the steps https://www.webrtc-experiment.com/docs/TURN-server-installation-guide.html#centos which is given in the link for centos.

and finally for running the command I have used this. turnserver -v -r ip:port -a -b turnuserdb.conf -c turnserver.conf -u turn-username:password

but after that I'm getting Cannot bind local socket to addr:PERMISSION DENIED like that I'm getting.

Any help?

@misi

de-saksham commented 4 years ago

@RamyaAshika Were you able to solve this issue? If yes, could you please help!

renaudallard commented 2 years ago

I have exactly the same issue if coturn doesn't run as root.

tlsharkey commented 2 years ago

systemctl may already be running coturn on your server (particularly if you install through apt). Try killing first (as sudo): systemctl stop coturn. Then running turnserver. Worked for me on Ubuntu 20.04 server.