- Text-to-Speech REST
- Text-to-Speech Streaming
- Models and Languages
- Media Output Settings
- Results Processing
- Tips and Tricks
- WebSocket Basics
- Establishing a WebSocket Connection
- Closing the WebSocket Connection
- Common WebSocket Errors
- Failure to Connect
- Debugging Connection Failures
- Abrupt WebSocket Closures
- Troubleshooting 1003 - MESSAGE-0000
- Troubleshooting 1008 - DATA-0000
- Troubleshooting 1008 - DATA-0001
- Troubleshooting 1009 - BIG-0000
- Troubleshooting 1009 - BIG-0001
- Troubleshooting 1011 - NET-0000
- Troubleshooting 1011 - NET-0001
- Troubleshooting 1011 - NET-0002
- Troubleshooting 1011 - NET-0003
TTS Troubleshooting WebSocket, NET, and DATA Errors
Learn how to debug common real-time, live streaming text-to-speech errors.
When working with Deepgram’s Text To Speech Streaming API, you may encounter WebSocket errors. This troubleshooting guide helps you quickly identify and resolve the most common issues.
WebSocket Basics
- WebSocket enables two-way, real-time communication between client and server.
- The connection is established via an HTTP handshake and upgraded to WebSocket.
- If the handshake fails, you’ll get an HTTP
4xxor5xxerror. - The connection stays open until closed by either side.
Establishing a WebSocket Connection
- The client initiates a WebSocket connection with an HTTP handshake, optionally including query parameters or headers (for authentication, etc.).
- Most libraries handle the handshake automatically (e.g.,
websockets.connect). - If successful, the server responds with HTTP
101and upgrades the connection. - If unsuccessful, you’ll receive an HTTP
4xxor5xxerror and the connection won’t be established.
Closing the WebSocket Connection
- A successfully opened WebSocket connection will stay alive until it is eventually closed by either the client or the server. When this occurs, aWebSocket Close Frame will be returned.
- The body of the Close frame will indicate the reason for closing with apre-defined status code followed by a UTF-8-encoded payload that represents the reason for the error.
- To close the WebSocket connection from your client, send aClose message. The server will then finish processing any remaining data, send a final response and summary metadata, and terminate the connection.
- After sending a Close message, the endpoint considers the WebSocket connection closed and will close the underlying TCP connection.
Common WebSocket Errors
Failure to Connect
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.
Debugging Connection Failures
If you’re unable to connect the Deepgram API provides custom HTTP headers that contain debugging information:
- Regardless of the success or failure of the WebSocket upgrade, all requests include the
dg-request-idHTTP header, which contains the request ID. - Requests that do not successfully upgrade to a WebSocket connection also include the
dg-errorHTTP 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.
Abrupt WebSocket Closures
If Deepgram encounters an error during real-time streaming, the Deepgram API returns aWebSocket Close frame. The body of the Close frame will indicate the reason for closing with apre-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.
| Code | Payload | Description |
|---|---|---|
| 1003 | MESSAGE-0000 | Input message isn’t a supported websocket message type. |
| 1008 | DATA-0000 | Input message isn’t recognized as a valid command. |
| 1008 | DATA-0001 | Too many input characters submitted in recent time window. |
| 1009 | BIG-0000 | Input message is too large. |
| 1009 | BIG-0001 | Input text has too many characters. |
| 1011 | NET-0000 | Internal server error. |
| 1011 | NET-0001 | Failed to receive message. |
| 1011 | NET-0002 | Failed to send message. |
| 1011 | NET-0003 | Time limit exceeded. |
Troubleshooting1003 -MESSAGE-0000
- Ensure you are sending supported TTS WebSocket message types of
text. - Refer to theDocumentation for valid message types.
Troubleshooting1008 -DATA-0000
- Make sure your message is a valid message type.
- Refer to theDocumentation for valid message types.
Troubleshooting1008 -DATA-0001
- Reduce the rate at which you are sending characters into the websocket via input messages.
- The limit is on the total number of characters submitted for speaking, not the distinct number of input messages used to submit those characters.
- Check theDocumentation for the maximum allowed character limit.
Troubleshooting1009 -BIG-0000
- Reduce the size of your input message.
- If sending large blocks of text, consider splitting it into smaller chunks.
- Check theDocumentation for the maximum allowed request body size.
Troubleshooting1009 -BIG-0001
- Shorten your input text to stay within character limits.
- Check theDocumentation for the maximum allowed character limit.
Troubleshooting1011 -NET-0000
- This indicates an internal server error.
- Retry your request.
- If the error persists, checkDeepgram status for outages.
- Contact Support if the issue continues.
Troubleshooting1011 -NET-0001
- The server did not receive a message from the client in time.
- Ensure your client is sending data promptly after connecting.
- Check for network issues or dropped connections.
- Retry the connection if needed.
Troubleshooting1011 -NET-0002
- The server failed to send a message to the client.
- Check your network connection and firewall settings.
- Retry the request.
- If the problem persists,contact Support.
Troubleshooting1011 -NET-0003
- The request took too long to complete (time limit exceeded).
- Try reducing the size or complexity of your request.
- Ensure your client is not waiting too long before sending or receiving data.
- Retry the request if appropriate.