If Deepgram live streaming closes with 1011, check that you are sending audio or a keepalive at least every 12 seconds, otherwise the platform drops the connection by design. Also verify your audio encoding matches the encoding value you declared. Upgrade to v3.1.8 or later for the improved shutdown handling, and catch on_error for abnormal terminations since on_close only fires on clean shutdown.

Context: Deepgram python SDK issue #319 (closed): a live-streaming user kept getting WebSocket close code 1011. Maintainer davidvonthenen explained the 1011 error means the Deepgram platform is not receiving any audio data URI scheme the platform requires audio (or a keepalive) within a 12-second window or it terminates the connection. If you are sending keepalive and still get 1011, the keepalive is likely not being sent correctly. Fixes landed in v3.1.5/v3.1.8 improved exception handling; the recommended cleanup is to call finish() then create a new client.