Skip to content

tls_port config value ignored in embedded TURN ICE URL — hardcodes port 443 #4542

Closed

Description

@simllll

Describe the bug

In pkg/service/roommanager.go, iceServersForParticipant checks TLSPort > 0 to decide whether to add a TURNS entry, but then ignores the configured value and hardcodes 443:

// pkg/service/roommanager.go ~line 1031
if r.config.TURN.TLSPort > 0 {
    urls = append(urls, fmt.Sprintf("turns:%s:443?transport=tcp", r.config.TURN.Domain))
    //                                             ^^^ should be %d + r.config.TURN.TLSPort
}

TLSPort is a documented, parsed config field (TLSPort int \yaml:"tls_port,omitempty"`inTURNConfig) — so configuring e.g. tls_port: 5349` correctly starts the TURN listener on 5349, but the ICE config advertised to browsers still says port 443.

To reproduce

Set turn.tls_port to any port other than 443 (e.g. 5349), enable the embedded TURN server, and connect a browser client. The ICE config in the JoinResponse will contain turns:your-domain:443?transport=tcp regardless of the configured value.

Impact

If port 443 on your infrastructure doesn't route to the TURN server (e.g. it terminates WebSocket/signaling, or is used for HTTPS), browsers fail to gather relay candidates. ICE falls back to direct/srflx paths only, and connections fail for users behind strict NAT.

Expected behaviour

urls = append(urls, fmt.Sprintf("turns:%s:%d?transport=tcp", r.config.TURN.Domain, r.config.TURN.TLSPort))

Workaround

Deploy a TLS-passthrough SNI proxy (e.g. nginx with ssl_preread) on port 443 that routes the configured turn.domain SNI to the actual TURN listener port.

Versions affected

Confirmed present in v1.10.1, v1.11.0, v1.12.0, and current main (cde89627). No existing issue found.

Activity

  1. cnderrauber commented on May 27, 2026

    @cnderrauber
    Contributor

    This is documented in config-sample, which states that you should use a load balancer for this case. Your workaround is expected.

    #   # defaults to 5349 - if not using a load balancer, this must be set to 443
    #   tls_port: 5349
    #
    
  2. simllll commented on May 27, 2026

    @simllll
    Author

    Okay, thanks for letting me know.
    Curious if there is any specific reasoning for this behavior? What's the config value for then?

  3. biglittlebigben commented on May 27, 2026

    @biglittlebigben
    Contributor

    TURN server behind a load balancer, which is a typical setup

  4. simllll commented on May 27, 2026

    @simllll
    Author

    Yeah I understand, but what is this config var for then at all? It would still be possible to leave the default to 443 or explicitly set it to. It's a bit confusing for me, but if this is intended im fine with it ;-)

  5. biglittlebigben commented on May 27, 2026

    @biglittlebigben
    Contributor

    443 needs to be exposed to the outside because that's the only port allowed to send TLS traffic in many network setups (firewalls). Behind the load balancer, having tuen on a different port makes it easier to run the service as non privileged user and to share the node in non Kubernetes, or host networked deployment.

  6. simllll commented on May 27, 2026

    @simllll
    Author

    I see, makes sense. Thanks!
    The config option only sets the listener port,but intentionally not the advertised port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions