For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Ask AIPlaygroundLoginFree API Key
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
HomeAPI ReferenceVoice AgentSpeech-to-TextText-to-SpeechIntelligenceSelf-Hosted Deployments
    • Getting Started with Speech to Text
  • Pre-Recorded Audio
    • Getting Started
    • Feature Overview
    • Template Apps
  • Streaming Audio
      • Getting Started
      • Feature Overview
      • Live Streaming Starter Kit
      • Template Apps
        • End of Speech Detection While Live Streaming
        • Using Interim Results
        • Endpointing & Interim Results With Live Streaming
        • Determining Your Audio Format for Live Streaming Audio
        • Measuring Streaming Latency
        • STT Troubleshooting WebSocket, NET, and DATA Errors
        • Recovering From Connection Errors & Timeouts When Live Streaming
        • Using Lower-Level Websockets with the Streaming API
    • Compare Flux to Nova-3
  • Models and Languages
    • Models & Languages Overview
    • Languages Support
    • Language Detection
    • Multilingual Codeswitching
    • Model Options
    • Version
  • Formatting
    • Speaker Diarization
    • Dictation
    • Filler Words
    • Measurements
    • Numerals
    • Paragraphs
    • Profanity Filtering
    • Punctuation
    • Redaction
    • Smart Formatting
    • Supported Entity Types
    • Utterances
    • Utterance Split
  • Custom Vocabulary
    • Find and Replace
    • Keyterm Prompting
    • Keywords
    • Search
  • Media Input Settings
    • Channels
    • Encoding
    • Multichannel
    • Sample Rate
  • Results Processing
    • Understanding Word Confidence Scores
    • STT Callback
    • STT Tagging
    • Extra Metadata
  • Migrating
    • Migrating From Amazon Web Services (AWS) Transcribe to Deepgram
    • Migrating From Google Speech-to-Text (STT) to Deepgram
    • Migrating From OpenAI Whisper to Deepgram
    • Migrating from AssemblyAI Speech-to-Text to Deepgram
LogoLogo
Ask AIPlaygroundLoginFree API Key
On this page
  • WebSocket Basics
  • Establishing a WebSocket Connection
  • Closing the WebSocket Connection
  • Using KeepAlive Messages to Prevent Timeouts
  • Common WebSocket Errors
  • Failure to Connect
  • Debugging Connection Failures
  • Code Samples
  • Abrupt WebSocket Closures
  • Troubleshooting 1008 - DATA-0000
  • Troubleshooting 1011 - NET-0000
  • Troubleshooting 1011 - NET-0001
Streaming AudioTranscription (Nova-3)Tips and Tricks

STT Troubleshooting WebSocket, NET, and DATA Errors

Learn how to debug common real-time, live streaming transcription errors.

Was this page helpful?
Previous

Recovering From Connection Errors & Timeouts When Live Streaming

Learn how to implement real-time, live streaming transcription solutions for long-running audio streams.

Next
Built with

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.

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 4xx or 5xx error.
  • 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 101 and upgrades the connection.
  • If unsuccessful, you’ll receive an HTTP 4xx or 5xx error 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, a WebSocket Close Frame will be returned.
  • 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.
  • To close the WebSocket connection from your client, send a Close Stream 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.

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.

Using KeepAlive Messages to Prevent Timeouts

  • Send a KeepAlive message periodically to keep the connection open.
  • Doing this can prevent timeouts and NET-0001 errors (no audio received for 10 seconds).

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-id HTTP header, which contains the request ID.
  • Requests that do not successfully upgrade to a WebSocket connection also include the 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.

Code Samples

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.

1import websockets
2import json
3import asyncio
4
5async def main():
6 try:
7 async with websockets.connect('wss://api.deepgram.com/v1/listen',
8 # Remember to replace the YOUR_DEEPGRAM_API_KEY placeholder with your Deepgram API Key
9 extra_headers = { 'Authorization': f'token YOUR_DEEPGRAM_API_KEY' }) as ws:
10 # If the request is successful, print the request ID from the HTTP header
11 print('🟢 Successfully opened connection')
12 print(f'Request ID: {ws.response_headers["dg-request-id"]}')
13 await ws.send(json.dumps({
14 'type': 'CloseStream'
15 }))
16 except websockets.exceptions.InvalidStatusCode as e:
17 # If the request fails, print both the error message and the request ID from the HTTP headers
18 print(f'🔴 ERROR: Could not connect to Deepgram! {e.headers.get("dg-error")}')
19 print(f'🔴 Please contact Deepgram Support with request ID {e.headers.get("dg-request-id")}')
20
21asyncio.run(main())

Abrupt WebSocket Closures

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.

CodePayloadDescription
1008DATA-0000The payload cannot be decoded as audio. The payload either is not audio data or is a codec unsupported by Deepgram.
1011NET-0000The service has not transmitted a Text frame to the client within the timeout window. This may indicate an internal issue with Deepgram’s systems, or Deepgram may have not received enough audio data to transcribe a frame.
1011NET-0001The service has not received a Binary or Text frame from the client within the timeout window. This may indicate an internal issue with Deepgram’s systems, the client’s systems, or the network connecting them.

Troubleshooting 1008 - DATA-0000

  • Check the data being sent is valid audio.
  • Check the audio data is not empty.
  • If the audio data is valid, check whether the audio being sent is raw or containerized.
  • Write the audio data to a file to make sure it contains the expected audio and can be played back.
  • Ensure Encoding and Sample Rate parameters are set correctly.
  • See Audio Format For Live Streaming for more information.

Troubleshooting 1011 - NET-0000

  • This indicates an internal server error.
  • Retry your request.
  • Check Deepgram status to see if there are any ongoing issues.
  • If Deepgram is operational, contact Support for assistance.

Troubleshooting 1011 - NET-0001

  • Ensure audio is sent within 10 seconds of opening the connection.
  • You can send silent audio to keep the connection alive.
  • Using KeepAlive messages alone will not prevent closure; you must send at least one audio message.
  • Be sure to send a Close Stream message when done.
  • Test your network with cURL and Deepgram-hosted audio. See Generating Transcripts from the Terminal for more information.
  • Use a tool like Wireshark to confirm audio is leaving your network.