ionorg / ion-sfu

Pure Go WebRTC SFU

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

phil1205 opened this issue · comments

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
		}
...
}

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