purple-football-37316
10/18/2025, 12:26 AMpython complex-agents/drive-thru/drivethru_agent.py dev
but it is complaining
2025-10-17 17:27:01,152 - WARNING livekit.agents - failed to connect to livekit, retrying in 10s
Traceback (most recent call last):
File "/Users/haoyu/Workspace/livekit-examples/python-agents-examples/venv/lib/python3.13/site-packages/livekit/agents/worker.py", line 656, in _connection_task
ws = await self._http_session.ws_connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
)
^
File "/Users/haoyu/Workspace/livekit-examples/python-agents-examples/venv/lib/python3.13/site-packages/aiohttp/client.py", line 1100, in _ws_connect
raise WSServerHandshakeError(
...<5 lines>...
)
aiohttp.client_exceptions.WSServerHandshakeError: 401, message='Invalid response status', url='wss://test-n96ch9qz.livekit.cloud/agent'tall-airline-16756
10/18/2025, 12:26 AMtall-airline-16756
10/18/2025, 12:28 AM.env file is located in the same directory as drivethru_agent.py and includes the following details:
LIVEKIT_URL=wss://your-livekit-server.com
LIVEKIT_API_KEY=your-api-key
LIVEKIT_API_SECRET=your-api-secret
1. Double-check that your API key and secret are accurate and match what’s set up on your server.
2. Try generating a test token using the LiveKit CLI to verify your credentials work as expected:
lk token create --api-key devkey --api-secret secret --join --room test-room --identity test-user --valid-for 1h
1. If you’re using a development server, please ensure it’s running with livekit-server --dev.
2. Also, confirm that your tokens haven’t expired and are properly signed.
If you’re still experiencing issues after these steps, could you kindly let me know:
• What type of LiveKit server setup you’re using (Cloud, self-hosted, or development mode)?
• Whether you’re able to successfully create tokens using the CLI?
I’m here to help, so feel free to share any details or questions you have!
Sources: livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt_v2.py | Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki | Authentication | LiveKit Docs | LiveKit Server Platform | livekit/livekit_composite | DeepWiki | realtime-agents/openai-realtime-drive-thru.py