green-electrician-12072
09/12/2025, 5:40 PM{"message": "Unclosed client session\nclient_session: <aiohttp.client.ClientSession object at 0x7ebf381947d0>", "level": "ERROR", "name": "asyncio", "pid": 2091, "job_id": "AJ_DTaynzb8CR3n", "timestamp": "2025-09-12T17:39:38.559246+00:00"}
{"message": "Unclosed connector\nconnections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x7ebf0bfc74d0>, 7101465.3876549)])']\nconnector: <aiohttp.connector.TCPConnector object at 0x7ebf38194b90>", "level": "ERROR", "name": "asyncio", "pid": 2091, "job_id": "AJ_DTaynzb8CR3n", "timestamp": "2025-09-12T17:39:38.559710+00:00"}
{"message": "Unclosed client session\nclient_session: <aiohttp.client.ClientSession object at 0x7ebf0bff6fd0>", "level": "ERROR", "name": "asyncio", "pid": 2091, "job_id": "AJ_DTaynzb8CR3n", "timestamp": "2025-09-12T17:39:38.559852+00:00"}
{"message": "Unclosed connector\nconnections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x7ebf0bfc6870>, 7101462.006414252)])']\nconnector: <aiohttp.connector.TCPConnector object at 0x7ebf0bff7890>", "level": "ERROR", "name": "asyncio", "pid": 2091, "job_id": "AJ_DTaynzb8CR3n", "timestamp": "2025-09-12T17:39:38.560122+00:00"}
tall-airline-16756
09/12/2025, 5:40 PMtall-airline-16756
09/12/2025, 5:41 PMasync with
when making HTTP requests (for example, async with <http://session.post|session.post>(...)
). This helps ensure everything is cleaned up automatically.
• Explicitly close WebSocket connections: It's a good idea to wrap your WebSocket usage in try/finally
blocks and call await ws.close()
in the finally
section. This way, resources are properly released.
• Leverage the framework's session management: Consider using the http_session()
utility from livekit.agents.utils.http_context
. It works nicely with the job lifecycle and helps manage cleanup during shutdown.
• Cancel and await tasks properly: Make sure to cancel and await all tasks before closing connections to prevent any leftover operations.
Following these tips should really help you avoid those unclosed client session and connector errors in your app. If you have any questions or need further help, feel free to ask—I'm here to support you!
Sources: livekit-plugins/livekit-plugins-lmnt/livekit/plugins/lmnt/tts.py