An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
Hello Soender,
Welcome to Microsoft Q&A and Thank you for reaching out.
I understand that the WebSocket disconnect you’re seeing (close code 1006) is coming from the Realtime API side rather than your client. A 1006 generally means the server closed the connection abruptly without sending a proper close frame. With Azure’s Realtime endpoint, this can happen under a few specific conditions that aren’t always surfaced as explicit errors.
From similar cases we’ve handled, there are a few patterns worth calling out:
1. Why 1006 happens
A 1006 usually points to an internal service safeguard being hit things like idle timeouts, buffer pressure, audio arriving too fast, or the session running longer or “hotter” than expected. Azure’s Realtime service doesn’t currently emit a detailed error event before this happens, so the lack of a warning is expected.
2. Long, continuous audio streams can trigger early closes
Even though the max session duration is documented as ~30 minutes, continuous audio streaming (especially without natural pauses) can cause the server to end the session earlier sometimes anywhere in the 5–20-minute range. This is tied to pacing, buffer windows, and internal session-health checks.
3. Multiple workers can increase the likelihood
Running several Realtime sessions at the same time is supported, but concurrency and capacity vary by region. We’ve seen cases where multiple long-running, audio-heavy sessions trigger protective throttles, especially when the service is under higher load.
4. What helps reduce these disconnects
A few adjustments tend to stabilize things:
- Reconnect proactively every 5–10 minutes, rather than waiting for the 25–30 min ceiling.
- Pace audio chunks consistently (around 20–50 ms intervals), and avoid micro-bursts.
- After each transcription sequence, ensure the buffer is reset using:
{ "type": "input_audio_buffer.clear" } - Avoid long stretches of low-energy “silence” audio, which can keep buffers active unnecessarily.
- If supported by your client, send periodic heartbeat pings.
- Log all message types sometimes lesser-known events show up before the drop.
5. Why it’s hard to reproduce consistently
These disconnects usually appear only under real workloads, multiple streams, region-level load, or specific pacing patterns. That's why it feels random and doesn’t show any clear error in logs.
Make sure your API key and endpoint configuration are correct. Verify that the target URL is well-formatted and points to the correct Azure region for your deployment. You can refer to this documentation for further assistance: Realtime API via WebSockets.
I Hope this helps. Do let me know if you have any further queries.
If this answers your query, could you please take a moment to retake the survey by accepting this response? Your feedback is greatly appreciated.
Thank you!