I am deploying livekit server to AWS EKS in a priv...
# ask-ai
p
I am deploying livekit server to AWS EKS in a private VPC . Below is my helm chart values. I am enabling turn - which spins up a NLB in aws. However in the listener I only see listener for
TCP:443
inspite of providing the
udp_port
Any idea why ? Is this expected behaviour ? Is this reason why I am getting
could not establish pc connection
in a browser connected to the AWS account via VPN
Copy code
replicaCount: 1
terminationGracePeriodSeconds: 18000  # 5 hours for graceful shutdown

livekit:
  port: 7880  
  log_level: debug
  
  http_headers:
    "Access-Control-Allow-Origin": "*" 
    "Access-Control-Allow-Private-Network": "true"
  rtc:
    use_external_ip: false
    port_range_start: 50000
    port_range_end: 60000
    tcp_port: 7881

  keys:
    "xxxx": "xxxxx"
  
  turn:
    enabled: true
    domain: turn.dev.xxx.a-xxx.net  # Your private Route 53 domain
    tls_port: 443   
    udp_port: 3478  
    external_tls: true 
    serviceType: "LoadBalancer"
    serviceAnnotations:
      service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"
      service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
      service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
    service:
      ports:
        - name: turn-tls
          port: 443
          protocol: TCP
          targetPort: turn-tls
        - name: turn-udp
          port: 3478
          protocol: UDP
          targetPort: turn-udp
podHostNetwork: true


loadBalancer:
  type: alb
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: "internal"  # Internal ALB
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-2-2017-01
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
    alb.ingress.kubernetes.io/ssl-redirect: '443'
    alb.ingress.kubernetes.io/subnets: "subnet-xxx,subnet-xxx,subnet-xxx"
    # ACM certificate auto-discovery based on domain match
  
  tls:
    - hosts:
      - voice.dev.xx.a-xxx.net
t
Thanks for reaching out, mithun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The Network Load Balancer (NLB) in your AWS EKS setup currently only exposes a TCP:443 listener because the Helm chart's TURN service configuration doesn’t include a UDP port specification. Even though you’ve defined the
udp_port
in your values, it isn’t being reflected through the NLB due to this limitation in the Helm chart. To help you expose the TURN/UDP port on the NLB, you’ll need to make a small modification to the Helm chart’s
turnloadbalancer.yaml
template. Here’s a friendly step-by-step guide to walk you through it: 1. First, clone the LiveKit Helm chart repository. 2. Next, open the
livekit-server/templates/turnloadbalancer.yaml
file and add a new port definition under
spec.ports:
like this:
Copy code
yaml - port: 3478 targetPort: {{ .Values.livekit.turn.udp_port }} protocol: UDP
If you want better compatibility with firewalls, you can instead use port 443 for UDP:
Copy code
yaml - port: 443 targetPort: {{ .Values.livekit.turn.udp_port }} protocol: UDP
3. Then, update your
values.yaml
to set the
udp_port
. Using port 443 for UDP is often recommended if you’re working in environments with restrictive firewalls. 4. After that, apply the modified Helm chart using
helm install
or
helm upgrade
. 5. Lastly, please make sure your AWS Security Groups allow inbound UDP traffic on the port you’ve configured (whether that’s 3478 or 443). This should help get your TURN/UDP traffic flowing through the NLB smoothly. If you have any questions or need a hand with any of these steps, just let me know—I’m here to help! Sources: Deploying LiveKit | LiveKit Docs | Ports and firewall | LiveKit Docs | Firewall Tips | livekit-server/templates/service.yaml
p
can you provide the source for this suggestion
t
The suggestion to modify the Helm chart's
turnloadbalancer.yaml
template to include a UDP port specification comes from a few helpful sources that I'd love to share with you: • The Helm chart's default setup for TURN services currently defines only a TCP port mapping in the
turnloadbalancer.yaml
template. This is why the NLB creates just a TCP listener. () • Best practices recommend using UDP port 443 for TURN/UDP to ensure better compatibility, especially with restrictive firewalls. () • There’s guidance on how to expose TURN/UDP traffic properly through AWS security groups and network ACLs, which helps maintain smooth connectivity. () • WebRTC’s ICE prioritization and fallback mechanisms explain how TURN/UDP is used when higher-priority options don’t work out. () Putting all these pieces together, it really supports the idea of updating the Helm chart and configuring the NLB to allow UDP traffic. If you’d like, I’m here to walk you through any part of this or provide more details—just let me know!
p
is both listener tcp and udp needed or can i make this work with only tcp listener on port 443
t
LiveKit's TURN functionality works smoothly with just a TCP listener on port 443. TURN/TLS (TURN over TCP on port 443) is thoughtfully designed for situations where UDP traffic might be blocked, like in many corporate firewall settings. This mode uses TLS encryption, so the traffic looks just like regular HTTPS traffic, which usually passes through firewalls without a hitch. To get TURN/TLS up and running on port 443, please make sure your Helm chart includes the following configuration:
Copy code
turn:
  enabled: true
  tls_port: 443
  domain: turn.myhost.com
  cert_file: /path/to/turn.crt
  key_file: /path/to/turn.key
With this setup, your clients can seamlessly fall back to TURN/TLS whenever UDP isn’t an option, keeping your connectivity smooth without needing a UDP listener. If you have any questions or need a hand with this, just let me know—I’m here to help! Sources: Firewall Tips | Docs::Home | config-sample.yaml | Docs::Home | Deploying LiveKit | LiveKit Docs
p
in aws context what are cert_file: /path/to/turn.crt key_file: /path/to/turn.key
t
In the context of LiveKit's TURN configuration on AWS, cert_file and key_file are your TLS certificate and private key files that help enable TURN/TLS functionality. These files are important because the embedded TURN server uses them to securely terminate TLS connections, which is especially helpful when UDP or non-TLS TCP connections are blocked by firewalls. If you're deploying on Kubernetes in AWS, you'll usually store these certificate and key files in a Kubernetes Secret. You can create this secret with the following command: Sources: Running LiveKit on AWS | Docs::Home | pkg/service/turn.go | Docs::Home | livekit-server/templates/deployment.yaml
p
can I use a AWS acm certificate - if so how does yaml look like'
t
AWS ACM certificates can’t be used directly for LiveKit TURN/TLS because ACM doesn’t allow exporting the private key, which LiveKit’s embedded TURN server needs. But don’t worry, I’m here to help you navigate your options based on your deployment setup: 1. Kubernetes Deployments (EKS with ALB): - You can use ACM to secure your main domain through the ALB for HTTPS/SSL termination. - For TURN/TLS, you’ll need a separate certificate (like one from Let’s Encrypt) since LiveKit requires certificate and key files. - Here’s an example YAML configuration for TURN using a separate certificate:
Copy code
livekit:
  turn:
    enabled: true
    domain: turn.yourdomain.com
    tls_port: 443
    secretName: livekit-turn-tls-secret
- Then, import your TURN certificate into Kubernetes as a TLS Secret:
Copy code
kubectl create secret tls livekit-turn-tls-secret --cert turn.crt --key turn.key --namespace livekit
2. External TLS Termination (e.g., NLB with ACM): - If you’re using a load balancer to handle TLS termination, just enable external_tls: true in your configuration:
Copy code
turn:
  enabled: true
  domain: turn.yourdomain.com
  tls_port: 443
  external_tls: true
- In this setup, LiveKit doesn’t need cert_file or key_file because TLS is managed externally. 3. VM Deployments: - For EC2 or other non-Kubernetes setups, tools like Caddy can help you dynamically provision certificates from Let’s Encrypt or ZeroSSL. If you’d like, I’m happy to walk you through any of these steps or answer any questions you have! Just let me know. Sources: pkg/config/config.go | Running LiveKit on AWS | Deploy to a VM | LiveKit Docs | Deploy to Kubernetes | LiveKit Docs
p
External TLS Termination (e.g., NLB with ACM): - yes I want to do this - can you provide the helm values for the same
t
To configure LiveKit TURN with external TLS termination using an NLB and ACM, here are the required Helm chart values:
Copy code
livekit:
  turn:
    enabled: true
    domain: turn.yourdomain.com  # Must match the domain covered by your ACM certificate
    tls_port: 3478               # Port where LiveKit listens for decrypted TURN/TLS traffic
    udp_port: 443                # Recommended for firewall traversal
    external_tls: true           # Disable internal TLS termination; handled externally by NLB
    serviceType: LoadBalancer    # Ensures Kubernetes creates a LoadBalancer-type Service
Additional Steps for AWS NLB and ACM: 1. Issue Certificate via ACM: Please request or import a certificate for
turn.yourdomain.com
in ACM and make sure it’s properly validated. 2. Configure NLB: You’ll want to add a TLS listener on port 443 using the ACM certificate, forwarding the decrypted traffic to port 3478 (TCP) on your target group (LiveKit TURN pods). 3. Service Annotations (Optional): If you’d like, customize the NLB behavior with these annotations:
Copy code
livekit:
  turn:
    loadBalancerAnnotations:
      service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
      service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:region:account-id:certificate/certificate-id"
      service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
4. Security Groups: Be sure to allow inbound traffic on port 3478 (TCP) and port 443 (UDP) in your EC2 security groups. 5. DNS Configuration: Finally, point
turn.yourdomain.com
to the NLB’s DNS name. If you have any questions or need a hand with setting up the NLB or integrating ACM, just let me know—I’m here to help! Sources: livekit-server/templates/deployment.yaml | config-sample.yaml | Deploy to Kubernetes | LiveKit Docs | Docs::Home | Deploying LiveKit | LiveKit Docs
p
Copy code
can you review my final config -   turn:
    enabled: true
    domain: xx.xx.xx.a-xx.net  # Your private Route 53 domain
    tls_port: 443   
    udp_port: 3478  
    external_tls: true 
    serviceType: "LoadBalancer"
    serviceAnnotations:
      service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"
      service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
      service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
      service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:ap-southeast-2:xxx:certificate/xx-95d0-4491-9f72-xxx"
      service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
      service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
t
Your configuration for LiveKit TURN with external TLS termination looks mostly correct. Let’s walk through some key points together to make sure everything is spot on: • external_tls: Setting
external_tls: true
is the right move, as it tells LiveKit to expect unencrypted traffic on the
tls_port
(443 in your case). • Annotations: You’ve included the annotations for the AWS NLB nicely. Specifically: ◦
service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"
makes sure the NLB is internal. ◦
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
clearly specifies you’re using a Network Load Balancer. ◦
service.beta.kubernetes.io/aws-load-balancer-ssl-cert
correctly points to your ACM certificate ARN. ◦
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
ensures the backend protocol is TCP, which is perfect. ◦
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
indicates TLS termination happens on port 443. • tls_port: Setting
tls_port: 443
is valid since the NLB will handle TLS termination and forward unencrypted traffic to this port. • udp_port: Setting
udp_port: 3478
is optional but a great idea if your environment supports UDP traffic. Additional Notes: • Double-check that your NLB is set to terminate TLS on port 443 and forward decrypted traffic to port 443 (or your configured
tls_port
) on the LiveKit pods. • Make sure the domain
xx.xx.xx.a-xx.net
matches the ACM certificate’s domain since this is what clients will see as the TURN endpoint. • Confirm your security groups allow inbound traffic on port 443 (TCP) and port 3478 (UDP) if you’re using UDP. If you’d like, I’m here to help with a deeper dive into your Helm values or any other questions you might have! Just let me know. Sources: config-sample.yaml | livekit-server/values.yaml | Deploying LiveKit | LiveKit Docs | Docs::Home
p
• Confirm your security groups allow inbound traffic on port 443 (TCP) and port 3478 (UDP) if you’re using UDP. how do I do thi
t
To configure AWS security groups to allow inbound traffic on ports 443 (TCP) and 3478 (UDP), let's walk through the steps together: 1. Navigate to the AWS VPC Dashboard: Start by opening the AWS Management Console, head over to VPC, and then select Security Groups under the "Security" section. 2. Select the Relevant Security Group: Find and choose the security group linked to your LiveKit instance or the EC2 instance where your application is running. 3. Edit Inbound Rules: ◦ Click on the Inbound Rules tab and then select Edit Inbound Rules. ◦ Add these rules: ▪︎ Type: Custom TCP | Port Range: 443 | Source: 0.0.0.0/0 (or you can limit this to a specific IP range for extra security) ▪︎ Type: Custom UDP | Port Range: 3478 | Source: 0.0.0.0/0 1. Save the Rules: Once you've added these, just click Save rules to make sure your changes take effect. 2. Instance-Level Firewall (if applicable): If your instance uses a host-based firewall like firewalld on Linux, remember to open these ports there too. For example, using
firewall-cmd
, you can run:
Copy code
sudo firewall-cmd --zone public --permanent --add-port 443/tcp
sudo firewall-cmd --zone public --permanent --add-port 3478/udp
sudo firewall-cmd --reload
If you have any questions or need a hand with any of these steps, just let me know—I’m here to help! Sources: Ports and firewall | LiveKit Docs | Docs::Home | Docs::Home | Deploy to a VM | LiveKit Docs | Docs::Home
p
The issue is fixed now. I added ACM certificate to NLB lister for SSL termination. With this my clients are able to connect from VPN to the livekit webrtc
t
I'm so happy to hear that the issue is all sorted and your clients are connecting smoothly now! If anything else comes up or you ever need a hand, please don’t hesitate to reach out. We're here to help!
p
LiveKit's TURN functionality works smoothly with just a TCP listener on port 443. TURN/TLS (TURN over TCP on port 443) is thoughtfully designed for situations where UDP traffic might be blocked, like in many corporate firewall settings. -- does this impact the voice latency ? my connection is successful - but the voice is breaking continuously and its almost no coherent..
t
Using TURN/TLS (TCP on port 443) instead of TURN/UDP can sometimes affect voice latency and quality because of how TCP works. Since TCP ensures reliable and ordered packet delivery, it can introduce some extra delay and might cause audio issues like voice breaking or jitter, especially during real-time calls. To help you overcome these voice breaking issues, here are some friendly best practices you can follow: • Enable TURN/TLS: Make sure TURN/TLS is set up correctly with
external_tls: true
along with the right domain and certificate configuration. • Allow TCP Fallback: In your RTC configuration, set
allow_tcp_fallback: true
so clients can switch to TCP or TURN/TLS if UDP isn’t working. • Firewall Configuration: Open these important ports: ◦ TCP 443: For TURN/TLS and WebSocket signaling ◦ UDP 50000–60000: Recommended for the best WebRTC media performance ◦ TCP 7881: For ICE/TCP fallback • Force TURN/TLS: If you’re in a restrictive network, make sure your firewall allows
*.turn.livekit.cloud
on TCP 443 so TURN/TLS can be used smoothly. • Debug and Monitor: Don’t forget to use LiveKit’s debug simulation tools to test how TURN/TLS is performing and to help spot any connectivity issues. While TURN/TLS is great for keeping you connected in tough network situations, aiming for UDP connectivity when you can will usually give you the best audio experience. If you have any questions or need a hand with this, I’m here to help! Sources: Firewall Tips | Docs::Home | Deploying LiveKit | LiveKit Docs | pkg/service/turn.go | Docs::Home
p
how do I check if its possible to communicate via udp in my network
t
To check if UDP communication is possible in your network, let's go through these steps together: 1. Run LiveKit's Connection Test Utility: You can use the
ConnectionCheck
class in the LiveKit SDK to help diagnose the issue. For example: `const checker = new ConnectionCheck(url, token); const webrtcResult = await checker.checkWebRTC();`If you don’t see any public UDP candidates, it usually means UDP traffic might be blocked. 2. Inspect ICE Candidates: During the ICE process, take a look to see if there are candidates with
protocol: 'udp'
and public IPs. If these are missing, UDP is probably not available. 3. Compare UDP vs TCP Performance: You can use the
checkConnectionProtocol
method to compare metrics like bitrate, RTT, and jitter between UDP and TCP:
const result = await checker.checkConnectionProtocol();
4. Ensure Firewall Ports Are Open: It’s important to verify that these ports are open:Also, make sure clients allow outbound UDP traffic to the LiveKit server and
*.host.livekit.cloud
. ◦ UDP 50000–60000: Used for WebRTC media traffic ◦ UDP 3478: Used for TURN/UDP 1. Force TURN for Testing: To test if UDP is blocked, try configuring the client to use TURN only by setting: `connectOpts.rtcConfig = { iceTransportPolicy: 'relay' };`If the connection works only in this relay mode, it’s a strong sign that UDP is blocked. Please feel free to reach out if you want me to walk you through any of these steps or if you have any questions along the way! I’m here to help. Sources: pkg/rtcconfig/ip.go | Connecting to LiveKit | LiveKit Docs | Diagnosing Connection Errors with Connection Test Utility | src/connectionHelper/ConnectionCheck.ts | Firewall Tips
p
the basic issue right now is even after setting up the livekit helmchart values for udp in turn section - it is not configuring listener on turn NLB in aws. Is that a pre-requisite for UDP traffic flow
t
A UDP listener on the TURN NLB in AWS is essential for UDP traffic flow in LiveKit, but the Helm chart doesn’t set this up automatically. Instead, it depends on exposing the UDP port (like 3478) through the node’s host networking using hostPort. This means UDP traffic skips the NLB and needs to be routed straight to the node. To get UDP traffic flowing smoothly, here are a few things to check: • Security Groups: Make sure inbound UDP traffic on the TURN UDP port (e.g., 3478) is allowed in the security group attached to your nodes. • Routing: Confirm that clients can reach the node’s public IP directly for UDP traffic. This might mean adjusting DNS settings or exposing the node’s IP. • Optional NLB Configuration: If you'd like to use the NLB for UDP traffic, you’ll need to manually set up a UDP listener on the NLB and forward traffic to the TURN UDP port on the nodes. Since the Helm chart doesn’t include annotations for this, it has to be done separately. If you’d like, I’m here to help guide you through setting up the UDP listener or tweaking the security groups—just let me know! Sources: pkg/service/roommanager.go | Ports and firewall | LiveKit Docs | livekit-server/templates/service.yaml | Docs::Home | Docs::Home
p
Copy code
Connecting to signal connection via WebSocket

Connected to server, version 1.9.0.

Establishing WebRTC connection

udp xx.xx.xx.xx:52066 host (private)

tcp xx.xx.xx.xx:7881 host (private)

udp xx.xx.xx.xx:56673 host (private)

udp xx.xx.xx.xx:52554 host (private)

tcp xx.xx.xx.xx:7881 host (private)

udp xx.xx.xx.xx:51438 host (private)

Warning: error with ICE candidate: 701 Address not associated with the desired network interface. turns:xx.dev.xxx.a-xxx.net:443?transport=tcp

Warning: Server is not configured for ICE/TCP

Warning: No public IPv4 UDP candidates were found. Your server is likely not configured correctly

Can connect via TURN

Can publish audio

detected audio from microphone

published 106 audio packets

Can publish video

Error: Permission denied by system

Resuming connection after interruption

Fail
Here is the output from connection test done from https://livekit.io/connection-test .. I am in a corporate VPN when running this test on my browser and the livekit server is on aws private vpc. They are connected via direct connect / vpn
t
The errors in your connection test suggest there are some challenges with WebRTC connectivity, likely due to network restrictions and server settings. Don’t worry, I’m here to help you work through them! Here’s what you can do: • No public IPv4 UDP candidates were found: This usually means the server can’t find public UDP candidates. To address this: ◦ Try enabling
use_external_ip: true
in your LiveKit configuration so the server advertises its public IP. ◦ Make sure UDP ports 50000–60000 (or your configured range) are open in your AWS security group. ◦ Also, open UDP port 3478 to allow TURN/UDP traffic. • Server is not configured for ICE/TCP: This indicates the server isn’t accepting ICE connections over TCP. To fix this: ◦ Enable
rtc.tcp_port
in your configuration (for example,
tcp_port: 7881
). ◦ Confirm that TCP port 7881 is open in your AWS security group. • Corporate VPN Considerations: VPNs can sometimes block UDP traffic, which affects connectivity. To improve this: ◦ Allow outbound traffic to
*.livekit.cloud
on TCP:443 and UDP:50000–60000. ◦ Enable TURN/TLS on port 443 in your LiveKit configuration to better handle restrictive environments. Example Configuration:
Copy code
rtc:
  port_range_start: 50000
  port_range_end: 60000
  tcp_port: 7881
  use_external_ip: true
turn:
  enabled: true
  tls_port: 443
  domain: turn.yourdomain.com
  cert_file: /path/to/cert
  key_file: /path/to/key
If you have any questions or need a hand with these steps, just let me know—I’m here to support you! Sources: Configuring firewalls | LiveKit Docs | Connecting to LiveKit | LiveKit Docs | Docs::Home | config-sample.yaml | Ports and firewall | LiveKit Docs