Is anyone experiencing WebSocket Realtime Error on Chrome browser?

Since 2:00 AM PST on 15th Jan, we started to have trouble connecting with Realtime API on Chrome browser. Safari works fine. On Desktop when the Browser is supposed to ask for access to Mic/Speaker, it blows up. The error code is :(Error : Could not connect to "wss://api.openai.com/v1/realtime). The model is gpt-4o-realtime-preview-2024-10-01.

Is anyone else getting the error?

Below is my code:
async connect({ model } = { model: ‘gpt-4o-realtime-preview-2024-10-01’ }) {
if (!this.apiKey && this.url === this.defaultUrl) {
console.warn(No apiKey provided for connection to "${this.url}");
}
if (this.isConnected()) {
throw new Error(Already connected);
}
if (globalThis.document) {
/**
* Web browser
*/
if (this.apiKey) {
console.warn(
‘Warning: Connecting using API key in the browser, this is not recommended’,
);
}
const WebSocket = globalThis.WebSocket;
const ws = new WebSocket(${this.url}${model ? ?model={model}` : ''}`, [ 'realtime', `openai-insecure-api-key.{this.apiKey}, 'openai-beta.realtime-v1', ]); ws.addEventListener('message', (event) => { const message = JSON.parse(event.data); this.receive(message.type, message); }); return new Promise((resolve, reject) => { const connectionErrorHandler = () => { this.disconnect(ws); reject(new Error(Could not connect to “{this.url}"`)); }; ws.addEventListener('error', connectionErrorHandler); ws.addEventListener('open', () => { this.log(`Connected to "{this.url}”); ws.removeEventListener('error', connectionErrorHandler); ws.addEventListener('error', () => { this.disconnect(ws); this.log(Error, disconnected from “{this.url}"`); this.dispatch('close', { error: true }); }); ws.addEventListener('close', () => { this.disconnect(ws); this.log(`Disconnected from "{this.url}”); this.dispatch('close', { error: false }); }); this.ws = ws; resolve(true); }); }); } else { /** * Node.js */ const moduleName = 'ws'; const wsModule = await import(/* webpackIgnore: true */ moduleName); const WebSocket = wsModule.default; const ws = new WebSocket( 'wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01', [], { finishRequest: (request) => { // Auth request.setHeader('Authorization', Bearer {this.apiKey}`); request.setHeader('OpenAI-Beta', 'realtime=v1'); request.end(); }, }, ); ws.on('message', (data) => { const message = JSON.parse(data.toString()); this.receive(message.type, message); }); return new Promise((resolve, reject) => { const connectionErrorHandler = () => { this.disconnect(ws); reject(new Error(`Could not connect to "{this.url}")); }; ws.on('error', connectionErrorHandler); ws.on('open', () => { this.log(Connected to “{this.url}"`); ws.removeListener('error', connectionErrorHandler); ws.on('error', () => { this.disconnect(ws); this.log(`Error, disconnected from "{this.url}”); this.dispatch('close', { error: true }); }); ws.on('close', () => { this.disconnect(ws); this.log(Disconnected from “${this.url}”`);
this.dispatch(‘close’, { error: false });
});
this.ws = ws;
resolve(true);
});
});
}
}

2 Likes


same for me since yesterday midnight , i even tired changing to the latest model. The biggest mystery is it is inconsistent and not leaving any reason or trace for failed connection. If anyone faces please upvote this to OpenAI to quickly solve it. I tired it in various browsers like chrome, brave, edge, opera mini

2 Likes

Have you tried on Safari? Coz we are seeing it work on Safari but fail on Chrome.

1 Like

yes even in safari too, it is not working

2 Likes

So that may be something in addition or just erratic behavior. Coz for us, so far, it works on Safari but not on Chrome.

1 Like

Same for me – must be a rolling change as it started for me 1/19 10PM EDT

Note: If I use the Token Auth server vs client side API key I can get in , Seems to be they turned off the ability to use plain API key…???

dangerouslyAllowAPIKeyInBrowser: true,

not valid any longer?

1 Like

2:40 EDT

Weird – Its fixed — I am back using regular API key vs token…

So is it working for you now? It started to work for us a few days back. Just checking

Yes - I was experiencing the issue for about 16 hours… I was able to use code that leveraged the ephemeral token on client side but any with clear token would not auth… got denied – seemed header was hung up – not rejected but hung up… I did not get a 4XX back but could see header hung in console tools etc.

1 Like

It was same with us. OpenAI should investigate and tell us what happened. But I doubt that wd happen.

This problem has come back on Chrome.

Yes, doesn’t work again, not sure when it started, but it hasn’t been working for at least 24 hours now. This is just terrible.

1 Like

Have you contacted OpenAi Helpdesk? I did but they earlier said no problem. Now I did again but no response yet

Yes, and they replied me with some generic nonsense about checking my connection even when I described this problem happened to multiple people and even sent this thread to them.

1 Like

The same experience here. The screenshots they are asking I provided when I filed compliant. I also included my code.

This is really frustrating. Probably we can switch to Azure endpoint, but based on their pricing pages, they kept the higher prices even for the newest model, that sucks.

Or server to server connection (but not sure it works), but that will add quite overhead to my prototype.

1 Like

There is no way to say Azure would work either. I remember the good old days of 2021/2022 when Logan/Boris used to frequent this forum. The product was way more buggy at that time but they helped/provided information. Now, I doubt that anyone from OpenAi is paying attention to this forum. And Customer service, even when told to visit this link, appears to be ignoring. Does anyone know if we have any admin from OpenAi here?

Hey there - sorry to hear you are running into problems with Realtime right now. Folks on our side are checking to see if there are potential problems with Realtime happening at the moment, but there doesn’t seem to be anything obviously wrong right now. I myself have just tested with both WebRTC and WebSocket connections to Realtime, and haven’t experienced any problems. I tested both our sample console app and a few simple apps, and both interfaces are functioning as I would expect.

My best guess here would be that something network-related is causing problems for you - it would be helpful if you could provide:

  • A runnable code sample that reproduces the problem you are experiencing (not a partial snippet)
  • Detailed console logging (in text, not a screenshot) that shows the error message(s) you are receiving

Thanks, and hopefully we can get this sorted out!

2 Likes

Thanks. I am asking my engineering team to provide me this info and will post in a few minutes. Also, did you try console app on Chrome browser on Desktop (not on Safari and not on mobile). That is where we are seeing failure (Chrome on Desktop).

Thanks. The code I use to test this is the simplest ever. Just open DevTools on any website and put this into the console:

const ws = new WebSocket(‘wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-12-17’)

I get this error message immediately:

"VM211:1 WebSocket connection to ‘wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-12-17’ failed: "

No message is sent through the websockets and Chrome shows the message about “Provisional headers are shown” in the Network tab. With this code I shared, I should get a message from Openai saying something about a wrong or missing API key, but that is not happening.

It doesn’t work for me, nor my colleagues who are in different cities, thus have different connections.

What is interesting is that it works in Safari. So, it is definitely not network-related.