STT Troubleshooting WebSocket, NET, and DATA Errors
Learn how to debug common real-time, live streaming transcription errors.
Learn how to debug common real-time, live streaming transcription errors.
When working with Deepgram’s Speech To Text Streaming API, you may encounter WebSocket errors. This troubleshooting guide helps you quickly identify and resolve the most common issues.
4xx or 5xx error.websockets.connect).101 and upgrades the connection.4xx or 5xx error and the connection won’t be established.Sending an empty byte (e.g., b'') will cause unexpected closures. Avoid sending an empty byte accidentally by adding a conditional to check if the length of your audio packet is 0 before sending.
If a failure to connect occurs, Deepgram returns custom HTTP headers for debugging:
dg-request-id: Always present, contains the request ID.dg-error: Present on failed upgrades, contains the error message.Access to these headers will depend on the WebSocket library you are using. For example, browser-based WebSocket libraries like the JavaScript WebSocket library only allow access to HTTP header information for successful WebSocket connections.
If you’re unable to connect the Deepgram API provides custom HTTP headers that contain debugging information:
dg-request-id HTTP header, which contains the request ID.dg-error HTTP header, which contains a detailed error message concerning why the connection could not be upgraded. This error message is also sent back in the body of the HTTP response.These code samples demonstrate how to connect to Deepgram’s API using WebSockets, authenticate with your API key, and handle both successful and failed connection attempts by printing relevant request IDs and error messages for troubleshooting.
Replace YOUR_DEEPGRAM_API_KEY with your Deepgram API Key.
If Deepgram encounters an error during real-time streaming, the Deepgram API returns a WebSocket Close frame. The body of the Close frame will indicate the reason for closing with a pre-defined status code followed by a UTF-8-encoded payload that represents the reason for the error.
Below are the most common WebSocket Close frame status codes and their descriptions.
1008 - DATA-00001011 - NET-00001011 - NET-0001KeepAlive messages alone will not prevent closure; you must send at least one audio message.