ancient-iron-20196
10/17/2025, 11:28 AMtall-airline-16756
10/17/2025, 11:28 AMtall-airline-16756
10/17/2025, 11:30 AMancient-iron-20196
10/17/2025, 11:57 AMtall-airline-16756
10/17/2025, 11:58 AMConnectionError: could not establish pc connection. This means that the WebRTC peer connection (PC) between your client and the LiveKit server couldn't be set up, often because the transport manager timed out while trying to connect.
To help you get to the bottom of this, here are some steps you can try:
1. Use LiveKit's Connection Test tool to check your WebSocket, WebRTC, and TURN server connectivity. You can find it here: https://livekit.io/connection-test.
2. Look into possible network-related issues such as:
◦ Firewall settings that might be blocking necessary connections
◦ VPNs that could interfere with WebRTC traffic
◦ Restrictions on your corporate network
1. Take a look at your application logs for any extra error details that might give us more clues.
If the connection tests don’t go through, it’s a good sign that something at the network level is blocking the connection. In that case, you might want to check your firewall settings, try temporarily disabling any VPNs, or reach out to your IT team to ensure LiveKit connections are allowed.
Please feel free to reach out if you’d like help running these tests or understanding the results—I’m here to support you every step of the way!
Sources: src/api/SignalClient.ts | Diagnosing Connection Errors with Connection Test Utilityancient-iron-20196
10/17/2025, 12:26 PMtall-airline-16756
10/17/2025, 12:27 PMancient-iron-20196
10/17/2025, 12:41 PMtall-airline-16756
10/17/2025, 12:42 PMWorkerOptions.num_idle_processes is a setting that controls how many idle processes the LiveKit worker keeps ready and waiting to handle incoming jobs. This is a great way to reduce job startup latency because it pre-warms processes, so you don’t have to wait for new ones to spawn and initialize when jobs come in.
Here’s what happens when you increase this value:
• Positive: You’ll see reduced job startup latency, better responsiveness, and smoother handling of multiple jobs at once.
• Trade-offs: It does use more memory and CPU, and if job demand is low, some resources might go unused.
The best value really depends on your specific needs. Higher numbers mean quicker responses but more resource use, while lower numbers save resources but might cause some delay. If you’d like, I’m here to help you figure out the ideal setup for your situation—just let me know!
Sources: livekit-agents/livekit/agents/worker.py | Worker options | LiveKit Docsancient-iron-20196
10/17/2025, 12:43 PMtall-airline-16756
10/17/2025, 12:44 PMnum_idle_processes to around 12-15 on a single worker, assuming your hardware supports it (think 4+ cores and 8GB+ RAM). This way, you’ll have enough pre-warmed processes ready to go, helping to avoid any delays when new calls come in.
If you’re working with multiple workers, a good approach is to spread the load by setting num_idle_processes to about 6-8 per worker across 2-3 workers.
Starting with these settings is a great first step! Keep an eye on things like process spawn times, memory use, and CPU load to see how it’s performing, and adjust as needed. Feel free to reach out if you want help tweaking your setup or if you’d like to share more about your hardware so I can offer more personalized advice.
Sources: tests/test_ipc.py | Deploying to custom environments | LiveKit Docsancient-iron-20196
10/17/2025, 12:46 PMtall-airline-16756
10/17/2025, 12:47 PMancient-iron-20196
10/20/2025, 9:56 AMtall-airline-16756
10/20/2025, 9:57 AMrtc:
udp_port: 7882
This setup will route all UDP traffic through port 7882, which can make your firewall configuration much easier. If you’re looking for a bit more performance, you might consider using a small range of ports, like 7882-7892:
rtc:
udp_port: 7882-7892
Using a single port is great if your environment has strict firewall rules, but keep in mind it might become a bottleneck if there’s heavy traffic. A small range of ports offers a nice balance between simplicity and performance.
If you’d like, I’m here to guide you through the implementation or answer any other questions you might have about your setup. Just let me know!
Sources: Ports and firewall | LiveKit Docs | config-sample.yaml | pkg/rtcconfig/webrtc_config.go | Firewall Tipsancient-iron-20196
10/20/2025, 10:00 AMtall-airline-16756
10/20/2025, 10:00 AMrtc:
port_range_start: 50000
port_range_end: 50010
This way, you narrow it down to 11 ports, which usually works well for moderate traffic and helps keep the number of open ports manageable.
Option 2: Use a Single UDP Port
rtc:
udp_port: 7882
Here, all UDP traffic goes through port 7882, making firewall setup a bit simpler. Just a heads-up—it might get a little busy if the load gets heavy.
If you'd like, I’m here to help you step through these changes or chat about what they might mean for your setup. Just let me know!ancient-iron-20196
10/20/2025, 10:15 AMtall-airline-16756
10/20/2025, 10:16 AMrtc:
udp_port: 7882-7892
1. Make sure your firewall settings allow traffic on the ports you’ve configured (7881 for TCP and 7882 for UDP).
2. If you’re deploying in the cloud, enabling external IP discovery can be really helpful:
rtc:
use_external_ip: true
If you have any questions or want me to walk you through these steps, please don’t hesitate to ask. I’m here to help you get everything running smoothly!
Sources: config-sample.yaml | pkg/transport/udpmultimux.go | Firewall Tips | Protocol & WebRTC Stack | livekit/livekit_composite | DeepWiki | Ports and firewall | LiveKit Docsancient-iron-20196
10/20/2025, 10:19 AMtall-airline-16756
10/20/2025, 10:20 AMrtc:
stun_servers:
- stun:stun.l.google.com:19302
- stun:stun1.l.google.com:19302
TURN Servers: These come into play when direct connections can’t be made, relaying traffic for you. LiveKit has an embedded TURN server, which is a solid choice for production environments:
turn:
enabled: true
domain: turn.myhost.com
tls_port: 443
udp_port: 3478
cert_file: /path/to/cert.pem
key_file: /path/to/key.pem
TURN servers are especially helpful if you’re dealing with restrictive firewalls, since they allow traffic over TCP/TLS on port 443, which looks like regular HTTPS traffic.
If you have any questions or want me to walk you through these configurations or how they work, just let me know—I’m here to help!
Sources: pkg/config/config.go | Deploying LiveKit | LiveKit Docs | Documentation/CallGuide.md | Firewall Tipsancient-iron-20196
10/21/2025, 9:31 AMtall-airline-16756
10/21/2025, 9:31 AMancient-iron-20196
10/21/2025, 9:32 AMtall-airline-16756
10/21/2025, 9:33 AMancient-iron-20196
10/23/2025, 4:59 AMtall-airline-16756
10/23/2025, 5:00 AMancient-iron-20196
10/23/2025, 5:10 AMtall-airline-16756
10/23/2025, 5:11 AMexp claim) and show a friendly notification before it happens.
If you’d like, I’m here to help you set up this client-side monitoring or chat through how to handle token expiration in your app. Just let me know!
Sources: Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | Authentication | LiveKit Docs | Sources/LiveKit/Token/CachingTokenSource.swift | livekit-protocol/src/livekit.rs | Core Platform Architecture & Authentication | livekit/livekit_composite | D...ancient-iron-20196
10/23/2025, 5:13 AMtall-airline-16756
10/23/2025, 5:13 AMwith_ttl, it won’t automatically renew. The token expiration is checked only during the initial connection attempt, so your ongoing sessions will continue smoothly even if the token expires in the middle of a conversation. This happens because LiveKit uses a proactive token refresh mechanism to keep the media flowing without interruption.
If you’d like to enforce session limits or give users a heads-up about token expiration, you can add some client-side logic to keep an eye on the token’s expiration time and respond accordingly. I’d be happy to help you with that if you want—just let me know!ancient-iron-20196
10/23/2025, 5:13 AMtall-airline-16756
10/23/2025, 5:14 AMimport jwt
import datetime
def is_token_expired(token):
decoded = jwt.decode(token, options={"verify_signature": False})
exp = decoded.get("exp")
if not exp:
return True
expiration_time = datetime.datetime.fromtimestamp(exp)
current_time = datetime.datetime.utcnow()
return current_time >= expiration_time - datetime.timedelta(seconds=60)
# Example usage
token = "your_jwt_token_here"
if is_token_expired(token):
print("Token is expired or will expire soon!")
# Notify user or refresh token logic here
This example gently decodes the JWT token, checks the exp claim, and helps you determine if the token will expire within the next 60 seconds. Feel free to swap out the print statement with your own notification or token refresh logic to best fit your needs.
If you’d like, I’m here to help with more examples or support in another programming language—just let me know!
Sources: complex-agents/note-taking-assistant/note-taker-frontend/hooks/useConnectio... | Sources/LiveKit/Token/CachingTokenSource.swift | Authentication | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWikiancient-iron-20196
10/23/2025, 5:14 AMtall-airline-16756
10/23/2025, 5:15 AMentrypoint(ctx: JobContext) function, you actually don’t need to worry about handling token expiration yourself. LiveKit takes care of refreshing tokens automatically for connected clients, so your sessions stay valid without any extra effort from you.
Here’s a simple example of how you can use the entrypoint function:
async def entrypoint(ctx: JobContext):
await ctx.connect() # Automatically handles token lifecycle
# Rest of agent logic
...
The ctx.connect() call is what makes sure the token lifecycle is managed smoothly by the LiveKit server and SDKs. If you’d like, I’m happy to walk you through more details or share additional examples—just let me know!
Sources: Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | Authentication | LiveKit Docs | agents/src/job.ts | README.mdancient-iron-20196
10/23/2025, 5:16 AMtall-airline-16756
10/23/2025, 5:16 AMancient-iron-20196
10/23/2025, 5:26 AMancient-iron-20196
10/28/2025, 5:12 AM