Skip to content

Commit a470596

Browse files
committed
fix (chat): trying without server side turn credentials
1 parent 67b45f5 commit a470596

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/server/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ services:
2121
# Exposes Nginx (running on port 80 in the container) to port 5000 on the host.
2222
# This is the primary public-facing port for your entire application.
2323
- "5000:80"
24+
# Expose a range of UDP ports for WebRTC media streams.
25+
- "40000-49999:40000-49999/udp"
2426
depends_on:
2527
- postgres
2628
- chroma

src/server/main/voice/routes.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ async def send_status_update(status_dict: Dict[str, Any]):
169169
await self.send_message(json.dumps({"type": "status", "message": "listening"}))
170170
except Exception as final_e:
171171
logger.warning(f"Could not send final 'listening' status for user {user_id}, connection likely closed: {final_e}")
172+
173+
stream = None
172174

173175
async def get_credentials():
174-
# Use a reasonable TTL of 1 hour (3600 seconds) for client-side credentials.
175-
return await get_cloudflare_turn_credentials_async(hf_token=HF_TOKEN)
176+
creds = await get_cloudflare_turn_credentials_async(hf_token=HF_TOKEN, ttl=360_000)
177+
logger.info("Using Cloudflare TURN credentials for WebRTC connections: %s", creds)
178+
return creds
176179

177-
stream = None
180+
def get_server_credentials():
181+
creds = get_cloudflare_turn_credentials(hf_token=HF_TOKEN, ttl=360_000)
182+
logger.info("Using Cloudflare TURN server creds on server side: %s", creds)
183+
return creds
178184

179185
if ENVIRONMENT in ["dev-local", "selfhost"]:
180186
logger.info("Running in dev-local or selfhost mode, using no TURN server.")
@@ -185,15 +191,15 @@ async def get_credentials():
185191
)
186192
else:
187193
logger.info("Using Cloudflare TURN server for WebRTC connections.")
188-
# --- Instantiate the handler and create the FastRTC Stream ---
189194
stream = Stream(
190195
handler=MyVoiceChatHandler(),
191196
rtc_configuration=get_credentials,
192-
# server_rtc_configuration=get_cloudflare_turn_credentials(ttl=360_000),
197+
server_rtc_configuration=get_server_credentials(),
193198
modality="audio",
194199
mode="send-receive",
195200
)
196201

202+
197203
@router.post("/end", summary="End voice chat session")
198204
async def end_voice_session(rtc_token: str):
199205
if rtc_token in rtc_token_cache:

0 commit comments

Comments
 (0)