## What this fixes
A live transcription connection kept dying with `received 1011 (internal error) Deepgram did not receive audio data or a text message within the timeout window. See https://dpgr.am/net0001`. Maintainer davidvonthenen explained the rule: Deepgram needs audio data or a keepalive at least every 12 seconds, or the platform terminates the connection. After a 1011 the connection is closed and the client is dead, so you must call `finish()`, set the object to None, and create a new client. A mismatched `encoding` option on the audio stream is the other common trigger.
## The fix
The 1011 error means Deepgram went about 12 seconds without receiving audio data or a keepalive, so the platform closed the connection. Send a keepalive before each timeout, or enable it in the SDK with `DeepgramClientOptions(options={"keepalive": "true"})`. Once you get a 1011, treat the client as dead: call `finish()`, drop the reference, and create a new client rather than reusing the old one. Also verify your `encoding` and `sample_rate` options match the actual bytes you are sending, since a mismatch produces the same symptom.
Source: https://github.com/deepgram/deepgram-python-sdk/issues/319
## Why it happens
The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.
## Source
https://github.com/deepgram/deepgram-python-sdk/issues/319