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

[Turn with TLS] Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use" #634

Open
phil1205 opened this issue Dec 29, 2021 · 1 comment

Comments

@phil1205
Copy link

phil1205 commented Dec 29, 2021

Your environment.

  • Version: Release 1.11.0
  • Client: MAC OS 12.1 / Linux Ubuntu 21.10
  • Environement: Local Mac / OPS
  • Are you using a TURN server?: ion-sfu turn enabled in config.yaml
  • Other Information - dtlsListener is starting from same UDP port as the udpListener (PORT 3478)

What did you do?

I cloned the current version of Pion ION-SFU and made changes to config.yaml.

Standard config

[turn]
# Enables embeded turn server
enabled = false
# Sets the realm for turn server
realm = "ion"
# The address the TURN server will listen on.
address = "0.0.0.0:3478"
# Certs path to config tls/dtls
# cert="path/to/cert.pem"
# key="path/to/key.pem"
# Port range that turn relays to SFU
# WARNING: It shouldn't overlap webrtc.portrange
# Format: [min, max]
# portrange = [5201, 5400]

Changes to config

[turn]
enabled = true ### Change: enabled
realm = "ion"
address = "0.0.0.0:3478"
cert="certs/cert.pem" ### Change: commented out and set path
key="certs/key.pem" ### Change: commented out and set path
portrange = [5201, 5400] ### Change: commented out

With default configuration, the service is starting without problems.
Starting service inclusive turn (enabled = true), but without certificates, the service is starting as well (but with ssl handshake error because of no exisiting certificates.
After including cert & key, the service does not start.

Error:
[2021-12-29 14:03:16.237] [INFO] [main.go:95] => Config file loaded file=config.toml v=0
[2021-12-29 14:03:16.237] [INFO] [main.go:152] => --- Starting SFU Node --- v=0
[2021-12-29 14:03:16.238] [ERROR] [sfu.go:216] => Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use"

Comand:
go build ./cmd/signal/json-rpc/main.go && ./main -c config.toml -cert certs/cert.pem -key certs/key.pem

Has anybody a working solution?

What did you expect?

Working ION-SFU with TURN-server and TLS

What happened?

Port-blocking after setting up cert & key in turn config.yaml

Why does the error occur?

pkg/sfu/turn.go

// Starting updListener on 0.0.0.0:3478
udpListener, err := net.ListenPacket("udp4", conf.Address)
if err != nil {
	return nil, err
}
...
// only if cert and key is set
if len(conf.Cert) > 0 && len(conf.Key) > 0 {
...
		// Starting dtlsListener as well on UDP 0.0.0.0:3478 --> Error occurs
		a := &net.UDPAddr{IP: net.ParseIP(addr[0]), Port: int(port)}
		dtlsListener, err := dtls.Listen("udp4", a, dtlsConf)
		if err != nil {
			return nil, err
		}
...
}
@phil1205 phil1205 changed the title Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use" (Turn with TLS) Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use" Dec 29, 2021
@phil1205 phil1205 changed the title (Turn with TLS) Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use" [Turn with TLS] Could not init turn server err error="listen udp4 0.0.0.0:3478: bind: address already in use" Dec 29, 2021
@dannymn
Copy link

dannymn commented Jan 23, 2022

sharing the same issue as @phil1205 , any solution/fix ?

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

2 participants