Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot bind listener socket #21

Closed
logoff opened this issue Sep 16, 2015 · 24 comments
Closed

Cannot bind listener socket #21

logoff opened this issue Sep 16, 2015 · 24 comments

Comments

@logoff
Copy link

logoff commented Sep 16, 2015

I'm using turnserver-4.4.5.4 in Debian 8 Jessie, compiled by myself with default options.

When I try to launch turnserver I get this error in the log (with the -o option):

0: Trying to bind fd 22 to <1.2.3.4:3478>: errno=98
0: Cannot bind TLS/TCP listener socket to addr 1.2.3.4:3478
0: Trying to bind TLS/TCP listener socket to addr 1.2.3.4:3478, again...

Or this error in the standard output (without the -o option):

Cannot bind local socket to addr: Address already in use
0: Cannot bind TLS/TCP listener socket to addr 1.2.3.4:3478
0: Trying to bind TLS/TCP listener socket to addr 1.2.3.4:3478, again...

TCP or UDP 3478 port is not allocated at all and, in fact, the server runs for a few seconds and then process dies.

I found similar error with older versions and other distros here and tried the --ne=2 option, but then the server dies in the first connection.

@mom040267
Copy link
Contributor

You are probably running two turn server instances on your system.

Sent from my iPhone

On Sep 16, 2015, at 6:58 AM, Julio Carlos Barrera Juez notifications@github.com wrote:

I'm using turnserver-4.4.5.4 in Debian 8 Jessie, compiled by myself with default options.

When I try to launch turnserver I get this error in the log (with the -o option):

0: Trying to bind fd 22 to 1.2.3.4:3478: errno=98
0: Cannot bind TLS/TCP listener socket to addr 1.2.3.4:3478
0: Trying to bind TLS/TCP listener socket to addr 1.2.3.4:3478, again...
Or this error in the standard output (without the -o option):

Cannot bind local socket to addr: Address already in use
0: Cannot bind TLS/TCP listener socket to addr 1.2.3.4:3478
0: Trying to bind TLS/TCP listener socket to addr 1.2.3.4:3478, again...
TCP or UDP 3478 port is not allocated at all and, in fact, the server runs for a few seconds and then process dies.

I found similar error with older versions and other distros here and tried the --ne=2 option, but then the server dies in the first connection.


Reply to this email directly or view it on GitHub.

@logoff
Copy link
Author

logoff commented Sep 16, 2015

@mom040267 no, I checked it with ps and free listening ports with ss and netstat.

I investigated a bit, and I'm running the VM inside a NAT network and I suspect I can't open ports using the coturn way. I'm not an expert, but it seems something related with the "hairpin condition".

I configured relay address with the public IP address and listening IP address with the private one. Moreover I configured external IP address with both (public/private).

@mom040267
Copy link
Contributor

If the program cannot open a socket on an address, it means that the
address:port are unavailable. That's very simple.

May be, you are trying to open a public IP on the 'internal' system with
private IPs ?

Oleg

On Wed, Sep 16, 2015 at 7:40 AM, Julio Carlos Barrera Juez <
notifications@github.com> wrote:

@mom040267 https://github.com/mom040267 no, I checked it with ps and
the free listening ports with ss and netstat.

I investigated a bit, and I'm running the VM inside a NAT network and I
suspect I can't open ports using the coturn way. I'm not an expert, but
it seems something related with the "hairpin condition".

I configured relay address with the public IP address and listening IP
address with the private one. Moreover I configured external IP address
with both (public/private).


Reply to this email directly or view it on GitHub
#21 (comment).

@logoff
Copy link
Author

logoff commented Sep 17, 2015

@mom040267 as I said, the sockets are opened during a few seconds using --ne=2 but the program hangs. Anyway I will continue investigating.

@logoff
Copy link
Author

logoff commented Sep 25, 2015

I found the origin of the issue. It was a compilation failure. I compiled with Debian Squeezy and executed with Debian Jessie. It produced those bind errors. It was nothing related with NAT server or hairpinning. Thank you for the support.

@pathfinder2104
Copy link

I know this issue is closed, but a comment from mom catched my eye: May be, you are trying to open a public IP on the 'internal' system with
private IPs ?

I am trying the same, I want to understand why it won't work? Do I have to deploy it on a machine with public IP ??

@logoff
Copy link
Author

logoff commented Jun 13, 2017

Nope, this was not the issue. If you want to listen in private IP address, you need to use this configuration. It says for Amazon EC2 users, but it works for any private/public IP address configuration.

@pathfinder2104
Copy link

Cool, thank you I am already using the -X option from the command line.

@diegobill
Copy link

I am having the same problem but I installed coturn by "apt install coturn" (Version: 4.5.0.3-1build1). I installed in a VM with ubuntu 16.04 server 64bits.

I execute this command at VM with IP 10.67.125.28 (ejabberd and coturn installed here), my clients can access this IP (jsxc/jsxc#583 (comment)):

# turnserver -L 10.67.125.28 -a -f -r 10.67.125.28 -V
The log output:

0: log file opened: /var/log/turn_9185_2017-07-20.log
0: 
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.5.0.3 'dan Eider'
0: 
Max number of open files/sockets allowed for this process: 65535
0: 
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 32500 (approximately)
0: 

==== Show him the instruments, Practical Frost: ====

0: TLS supported
0: DTLS supported
0: DTLS 1.2 supported
0: TURN/STUN ALPN supported
0: Third-party authorization (oAuth) supported
0: GCM (AEAD) supported
0: OpenSSL compile-time version: OpenSSL 1.0.2g-fips  1 Mar 2016
0: 
0: SQLite supported, default database location is /var/lib/turn/turndb
0: Redis supported
0: PostgreSQL supported
0: MySQL supported
0: MongoDB is not supported
0: 
0: Default Net Engine version: 3 (UDP thread per CPU core)

=====================================================

0: Config file found: /etc/turnserver.conf
0: Listener address to use: 10.67.125.28
0: Listener address to use: 10.67.125.29
0: Relay address to use: 10.67.125.28
Cannot open DH file: No such file or directory
Cannot open DH file: No such file or directory
Cannot open DH file: No such file or directory
Cannot open DH file: No such file or directory
Cannot open DH file: No such file or directory
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address
bind: Cannot assign requested address
Cannot bind local socket to addr: Cannot assign requested address

@diegobill
Copy link

I tried these commands bellow too, but print the same error:

turnserver -L 10.67.125.28 -a -f -r 10.67.125.28 -V -X 10.67.125.28
turnserver -L 10.67.125.28 -a -f -r 10.67.125.28 -V -X 10.67.125.28/10.67.125.28
turnserver -L 10.67.125.28 -a -f -V -X 10.67.125.28/10.67.125.28
turnserver -a -f -V -X 10.67.125.28/10.67.125.28
turnserver -a -f -V -X 10.67.125.28

@diegobill
Copy link

I fixed the problem configuring two IPs in interfaces:

auto eth0
iface eth0 inet static
        address 10.67.125.28
        ...

auto eth0:0
iface eth0:0 inet static
        address 10.67.125.29
        ...

And enable turnserver (/etc/turnserver.conf):

#
# Uncomment it if you want to have the turnserver running as 
# an automatic system service daemon
#
TURNSERVER_ENABLED=1

@diegobill
Copy link

But video call still having problem, /var/log/turn/turn_2017-07-20.log :

1180: handle_udp_packet: New UDP endpoint: local addr 10.67.125.28:3478, remote addr 10.67.205.101:58266
1180: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1180: handle_udp_packet: New UDP endpoint: local addr 10.67.125.28:3478, remote addr 10.67.205.101:34669
1180: session 001000000000000012: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1180: IPv4. Local relay addr: 10.67.125.28:64297
1180: session 000000000000000013: new, realm=<10.67.125.28>, username=<>, lifetime=600
1180: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: IPv4. tcp or tls connected to: 10.67.205.101:39950
1181: IPv4. Local relay addr: 10.67.125.28:51413
1181: session 001000000000000013: new, realm=<10.67.125.28>, username=<>, lifetime=600
1181: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: IPv4. tcp or tls connected to: 10.67.205.101:39956
1181: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: IPv4. Local relay addr: 10.67.125.28:58309
1181: session 001000000000000012: new, realm=<10.67.125.28>, username=<>, lifetime=600
1181: session 001000000000000012: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: IPv4. tcp or tls connected to: 10.67.205.101:39954
1181: IPv4. Local relay addr: 10.67.125.28:62677
1181: session 000000000000000014: new, realm=<10.67.125.28>, username=<>, lifetime=600
1181: session 000000000000000014: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1181: IPv4. tcp or tls connected to: 10.67.205.101:39952
1181: IPv4. tcp or tls connected to: 10.67.205.101:39960
1181: IPv4. tcp or tls connected to: 10.67.205.101:39958
1182: session 000000000000000014: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1182: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1182: session 001000000000000012: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1182: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1182: session 000000000000000014: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1183: session 000000000000000014: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1184: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1184: session 001000000000000012: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: handle_udp_packet: New UDP endpoint: local addr 10.67.125.28:3478, remote addr 10.67.123.120:58088
1185: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1185: IPv4. Local relay addr: 10.67.125.28:61185
1185: session 000000000000000017: new, realm=<10.67.125.28>, username=<>, lifetime=600
1185: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: session 000000000000000014: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: IPv4. tcp or tls connected to: 10.67.123.120:50605
1185: IPv4. Local relay addr: 10.67.125.28:61486
1185: session 000000000000000018: new, realm=<10.67.125.28>, username=<>, lifetime=600
1185: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: session 000000000000000015: TCP socket closed remotely 10.67.205.101:39960
1185: session 000000000000000015: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39960, reason: TCP connection closed by client (callback)
1185: session 001000000000000014: TCP socket closed remotely 10.67.205.101:39956
1185: session 001000000000000014: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39956, reason: TCP connection closed by client (callback)
1185: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1185: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1186: session 000000000000000014: TCP socket closed remotely 10.67.205.101:39954
1186: session 000000000000000014: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39954, reason: TCP connection closed by client (callback)
1186: session 000000000000000014: delete: realm=<10.67.125.28>, username=<>
1186: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1186: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1187: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1187: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1188: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1188: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1189: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1189: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1190: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1193: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1193: session 000000000000000018: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1195: session 000000000000000017: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1196: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1196: session 001000000000000013: realm <10.67.125.28> user <>: incoming packet ALLOCATE processed, success
1200: session 000000000000000018: TCP socket closed remotely 10.67.123.120:50605
1200: session 000000000000000018: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.123.120:50605, reason: TCP connection closed by client (callback)
1200: session 000000000000000018: delete: realm=<10.67.125.28>, username=<>
1200: session 000000000000000013: realm <10.67.125.28> user <>: incoming packet BINDING processed, success
1200: session 001000000000000013: TCP socket closed remotely 10.67.205.101:39950
1200: session 001000000000000013: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39950, reason: TCP connection closed by client (callback)
1200: session 001000000000000013: delete: realm=<10.67.125.28>, username=<>
1200: session 001000000000000015: TCP socket closed remotely 10.67.205.101:39952
1200: session 001000000000000015: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39952, reason: TCP connection closed by client (callback)
1200: session 000000000000000016: TCP socket closed remotely 10.67.205.101:39958
1200: session 000000000000000016: closed (2nd stage), user <> realm <10.67.125.28> origin <>, local 10.67.125.28:3478, remote 10.67.205.101:39958, reason: TCP connection closed by client (callback)

JSXC config:

RTCPeerConfig: {
         /** Time-to-live for config from url */
         ttl: 3600,

         /** [optional] If set, jsxc requests and uses RTCPeerConfig from this url */
         url: null,

         /** If true, jsxc send cookies when requesting RTCPeerConfig from the url above */
         withCredentials: false,

         /** ICE servers like defined in http://www.w3.org/TR/webrtc/#idl-def-RTCIceServer */
         iceServers: [{
            urls: 'stun:10.67.125.28',
         },{
            urls: 'turn:10.67.125.28:3478?transport=udp',
            username: 'USERNAME',
            credential: 'USERPASSWORD',
            credentialType: 'password'
         },{
            urls: 'turn:10.67.125.28:3478?transport=tcp',
            username: 'USERNAME',
            credential: 'USERPASSWORD',
            credentialType: 'password'
         }]
      }

@highdev2016
Copy link

Hello, guys.
I've installed turnserver-4.5.0.6 on my server and executed "turnserver -L xx.xx.xx.xx -a -f -r north.gov" on the terminal.
Then I got this error on the log:

1: Trying to bind fd 22 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
bind: Cannot assign requested address
bind: Cannot assign requested address
1: Trying to bind fd 28 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Trying to bind fd 27 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
1: Cannot bind DTLS/UDP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind DTLS/UDP listener socket to addr xx.xx.xx.xx:3478, again...
bind: Cannot assign requested address
1: Trying to bind fd 12 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
bind: Cannot assign requested address
1: Trying to bind fd 17 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
bind: Cannot assign requested address
1: Trying to bind fd 22 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
bind: Cannot assign requested address
bind: Cannot assign requested address
1: Trying to bind fd 28 to <xx.xx.xx.xx:3478>: errno=99
Cannot bind local socket to addr: Cannot assign requested address
1: Trying to bind fd 27 to <xx.xx.xx.xx:3478>: errno=99
1: Cannot bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478
Cannot bind local socket to addr: Cannot assign requested address
1: Trying to bind TLS/TCP listener socket to addr xx.xx.xx.xx:3478, again...
1: Cannot bind DTLS/UDP listener socket to addr xx.xx.xx.xx:3478
1: Trying to bind DTLS/UDP listener socket to addr xx.xx.xx.xx:3478, again...

xx.xx.xx.xx is the public IP address of the server.
So I executed 'ifconfig' to check the inet address.
But I can get like this.

eth0 Link encap:Ethernet HWaddr 52:54:00:33:4C:3A
inet addr:10.163.5.60 Bcast:10.163.127.255 Mask:255.255.128.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:75376879 errors:0 dropped:0 overruns:0 frame:0
TX packets:55628433 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7322117114 (6.8 GiB) TX bytes:6418093666 (5.9 GiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:835 errors:0 dropped:0 overruns:0 frame:0
TX packets:835 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:63197 (61.7 KiB) TX bytes:63197 (61.7 KiB)

10.163.5.60 is the private address of this server.
The public address is correct. And I created the server from qcloud.com.
How can I fix this issue?
Thanks.

@pathfinder2104
Copy link

pathfinder2104 commented Aug 11, 2017 via email

@highdev2016
Copy link

Thanks for your replying.
But I can connect the server with public ip address. eg. 80, 3306, 8080 ... etc.
I think the server has live public ip already.

@sterlingfire
Copy link

Did you ever solve this?

@RamyaAshika
Copy link

I'm also having the same issue. What to do for this?

@RamyaAshika
Copy link

I fixed the problem configuring two IPs in interfaces: @diegobill How you fixed and where you kept that two IPs

@RamyaAshika
Copy link

Hello did you fixed this?Facing the same problem. @highdev2016

@hiwwx
Copy link

hiwwx commented Feb 19, 2019

Hello, did you fixed this problem?@RamyaAshika

@victorbw
Copy link

i dont wanna give you to much hope on this, but i guess it could help to give it an additional port range to communicate on:

coturn.conf:

uncomment

min-port=49152
max-port=65535

@misi
Copy link
Contributor

misi commented Apr 29, 2019

Check that your process is not stuck

ps aux | grep turnserver

And check open ports and process

netstat -lnp

Stop or kill your stuck process and after it you can start your coturn..

@shakingWaves
Copy link

#listening-device=eth0
listening-ip=xxx
#relay-device=eth0
relay-ip=yyy
configure as this may work!

@ivy-reps
Copy link

ivy-reps commented Apr 3, 2022

#21 (comment)

I think you need to bind it to your local server and then do a port
forwarding from your static ip to local server. Or you should put it on the
machine which has the live ip.

@pathfinder2104, that's the point! I'm just removed --relay-ip='$$(detect-external-ip)' command field of docker-compose.yml and now it is working! Camera and calls of Synapse works well! Thank you very much!

Here is why it's important:
turnserver --help

 -E, --relay-ip         <ip>                    Relay address (the local IP address that will be used to relay the
                                                packets to the peer).

By trying to configure Turn fastly, I tried different configurations, which was done by others, but I didn't knew how it will affect on functionality inside docker which in context of docker-compose configured to work in Bridge networking mode. So, in context of non host type of networking, probably you have not to use that parameter for external IP value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests