pipecat version
0.0.108
Python version
3.13.5
Operating System
Linux (Debian 13, x86_64)
Issue description
File: pipecat/services/deepgram/tts.py — stop() / _disconnect() teardown path
Related: pipecat/services/websocket_service.py — _maybe_try_reconnect
Severity: Low — no functional impact on completed calls, but leaks an open WebSocket connection and generates hourly error noise.
What happens
After a pipeline runs to completion (EndFrame processed, runner.run() returns), the DeepgramTTSService's underlying WebSocket connection remains open. Deepgram times out idle connections with a 1011 internal error (NET-0003) after ~60 minutes. Because _disconnecting is False at that point (suggesting _disconnect() was either not called or its effect didn't persist to the receive task), _maybe_try_reconnect treats this as a recoverable error, reconnects, and the cycle repeats every hour until the process restarts.
Suspected cause
Possible race between the receive task being cancelled and Deepgram sending its 1011 — or _disconnect() completing but _disconnecting being reset before the 1-hour timeout fires. Needs reproduction with a controlled sleep/disconnect sequence.
Reproduction steps
- Create a pipeline with DeepgramTTSService and RTVIProcessor
- Run a call to completion (pipeline processes EndFrame naturally — e.g. agent says goodbye and hangs up)
- Confirm runner.run() returns and the "Finally block" is reached in logs
- Wait ~60 minutes
- Observe logs
Expected behavior
stop(EndFrame) → _disconnect() sets _disconnecting = True and cancels _receive_task. After that, any close event from Deepgram should hit the _disconnecting guard in _maybe_try_reconnect and exit the receive loop without reconnecting.
Actual behavior
After runner.run() returns, DeepgramTTSService's WebSocket connection remains open.
Deepgram times out the idle connection after ~60 minutes with a 1011 internal error (NET-0003).
Because _disconnecting is False at that point, _maybe_try_reconnect treats it as a recoverable
error, reconnects successfully, and the cycle repeats every hour indefinitely until the process
restarts.
Logs
● 2026-05-03 07:32:54 | INFO | main:_post_call_cleanup - Call record saved — completed, summary: ready
2026-05-03 07:32:54 | INFO | main:websocket_endpoint - Finally block reached
# ~60 minutes pass, no activity
2026-05-03 08:30:34 | WARNING | pipecat.services.websocket_service:_maybe_try_reconnect:149 - DeepgramTTSService#2 connection closed, but with an error: received 1011 (internal error) NET-0003; then sent 1011 (internal error) NET-0003
2026-05-03 08:30:34 | WARNING | pipecat.services.websocket_service:_try_reconnect:86 - DeepgramTTSService#2 reconnecting, attempt 1
2026-05-03 08:30:34 | WARNING | pipecat.services.websocket_service:_reconnect_websocket:66 - DeepgramTTSService#2 reconnecting (attempt: 1)
2026-05-03 08:30:34 | DEBUG | pipecat.services.deepgram.tts:_connect_websocket:233 - DeepgramTTSService#2: Websocket connection initialized
2026-05-03 08:30:34 | INFO | pipecat.services.websocket_service:_try_reconnect:88 - DeepgramTTSService#2 reconnected successfully on attempt 1
# repeats every 60 minutes:
2026-05-03 09:30:34 | WARNING | pipecat.services.websocket_service:_maybe_try_reconnect:149 - DeepgramTTSService#2 connection closed, but with an error: received 1011 (internal error) NET-0003; then sent 1011 (internal error) NET-0003
2026-05-03 10:30:34 | WARNING | pipecat.services.websocket_service:_maybe_try_reconnect:149 - DeepgramTTSService#2 connection closed, but with an error: received 1011 (internal error) NET-0003; then sent 1011 (internal error) NET-0003
pipecat version
0.0.108
Python version
3.13.5
Operating System
Linux (Debian 13, x86_64)
Issue description
File:
pipecat/services/deepgram/tts.py—stop()/_disconnect()teardown pathRelated:
pipecat/services/websocket_service.py—_maybe_try_reconnectSeverity: Low — no functional impact on completed calls, but leaks an open WebSocket connection and generates hourly error noise.
What happens
After a pipeline runs to completion (EndFrame processed,
runner.run()returns), theDeepgramTTSService's underlying WebSocket connection remains open. Deepgram times out idle connections with a 1011 internal error (NET-0003) after ~60 minutes. Because_disconnectingisFalseat that point (suggesting_disconnect()was either not called or its effect didn't persist to the receive task),_maybe_try_reconnecttreats this as a recoverable error, reconnects, and the cycle repeats every hour until the process restarts.Suspected cause
Possible race between the receive task being cancelled and Deepgram sending its 1011 — or
_disconnect()completing but_disconnectingbeing reset before the 1-hour timeout fires. Needs reproduction with a controlled sleep/disconnect sequence.Reproduction steps
Expected behavior
stop(EndFrame)→_disconnect()sets_disconnecting = Trueand cancels_receive_task. After that, any close event from Deepgram should hit the_disconnectingguard in_maybe_try_reconnectand exit the receive loop without reconnecting.Actual behavior
After runner.run() returns, DeepgramTTSService's WebSocket connection remains open.
Deepgram times out the idle connection after ~60 minutes with a 1011 internal error (NET-0003).
Because _disconnecting is False at that point, _maybe_try_reconnect treats it as a recoverable
error, reconnects successfully, and the cycle repeats every hour indefinitely until the process
restarts.
Logs