Using nodejs connecting from server side.
I’m running into this issue that some time around 5-10 minutes in - response.text.delta
server event starts to respond slowly and my websocket connection disconnects.
I then get error RealtimeAPI is not connected
from here: openai-realtime-api-beta/lib/api.js at main · openai/openai-realtime-api-beta · GitHub with eventName="input_audio_buffer.append"
.
Modifying the close
listener here: openai-realtime-api-beta/lib/api.js at main · openai/openai-realtime-api-beta · GitHub to ws.on('close', (code, reason)
I get code=1011
with reason="keepalive ping timeout"
Looking at the rate_limits.updated
event. I’m hitting neither the token limit cap, or the 15-minute session timer cap.
Is there another mechanism from OpenAI side that throttles requests and would cause this disconnect?
2 Likes
I figured it out—you need to monkey patch the api.js in the library with a keep-alive ping-pong mechanism. The base library currently doesn’t support long-running monologues well.
3 Likes
jill7
December 16, 2024, 7:59pm
3
Thanks for sharing - I am running into the same issue! I notice the connection closes after just 1-2 minutes.
Mind sharing your patch? I added the ‘ping’ but got an error as the event type is unsupported, so figure it’s missing the ‘pong’
Also, what are you noticing in practice is a duration for a “long running monologue” that’s unsupported?
jill7
December 16, 2024, 8:00pm
4
@hemlocket tagging in case it doesn’t notify
sps
December 18, 2024, 2:49am
5
The maximum session length has been increased from 15 minutes to 30 minutes on the Realtime API beta.
Here’s the latest announcement:
A bunch of big updates for the Realtime API today. We’re announcing support for WebRTC, meaning you can add speech-to-speech experiences with just a handful of lines of code . (A bunch of you asked after the Rudolph toy demo in the livestream for the embedded SDK — Sean has published it to Github here ). We’ve also released two new snapshots:
gpt-4o-realtime-preview-2024-12-17 , which has improved voice quality and more reliable input, and with 60%+ cheaper audio.
gpt-4o-mini-realtime-preview-20…
1 Like
@hemlocket - I’d love to know more about your patch, I’m running into the same issue on my end.
I was having an issue like this. OpenAI’s websocket server sends pings with a 20 second keepalive, so if you don’t respond with pong before that it will disconnect. It sends an array of bytes in the ping and you have to pong with the same bytes.
I am facing similar issue. I am not using any openai client SDK, just using raw endpoint and nodejs ws library.
Even after implementing explicit pong replies at client side, still I randomly see some of my clients disconnecting with.
Disconnected from OpenAI code: 1011 reason: keepalive ping timeout
This is what I am doing at client side
client.on('ping', (data) => {
client.pong(data);
});
@hemlocket @chrisacker would be great if you help the community please for solving this issue.