Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

connectOpenAi fails with `server_error code 42` on 0.4.2

Offen
#321 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
node.js, typescript

Rechercherichtung

Beginne beim TypeScript-Aufruf connectOpenAi und verfolge seine Anfrage bis zum Stream-Endpunkt /video/connect_agent unter Verwendung der aufgeführten SDK-Versionen. Reproduziere den Ablauf mit dem bereitgestellten Webhook und vergleiche den weitergereichten Fehler code 42 mit einer direkten OpenAI-Realtime-Verbindung. Als erledigt gilt die Aufgabe, wenn derselbe gültige Schlüssel einen Agenten ohne den undurchsichtigen Serverfehler mit einem Stream-Videoanruf verbinden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Summary

stream.video.connectOpenAi(...) consistently fails with server_error code 42 when connecting an OpenAI Realtime agent to a call. I have isolated the cause: the same OpenAI API key connects directly to OpenAI's GA Realtime API without error, so the key/account/access are fine. I guess the failure is still inside Stream's /video/connect_agent → OpenAI path.

Bumping to 0.4.2 (as advised on my previous, now-closed ticket) did not change the result.

What I'm trying to do

Connect an OpenAI Realtime (speech-to-speech) agent to a Stream Video call so it joins as a participant and talks. It's triggered server-side from the call.session_started webhook: look up the meeting/agent, then call connectOpenAi.

const call = stream.video.call("default", meetingId);
const client = await stream.video.connectOpenAi({
  call,
  openAiApiKey: process.env.OPENAI_API_KEY, // sk-proj-36XU_...
  agentUserId: agent.id,
});
client.updateSession({ instructions });

No model is passed, so it defaults to gpt-realtime (GA).

Environment

  • @stream-io/node-sdk: 0.7.62
  • @stream-io/openai-realtime-api: 0.4.2
  • @stream-io/video-react-sdk: 1.39.1 (client)
  • Next.js: 16.2.10

What's failing

connectOpenAi rejects. The client only surfaces the opaque code 42:

Error: Stream connect_agent failed (code 42): Error:  code
{
  type: 'error',
  error: { type: 'server_error', code: '42', message: 'Error:  code ', param: null, event_id: '' }
}

The webhook itself is fine, signature verification passes (HTTP 200 via verifyAndParseWebhook on the raw gzipped body); the 500 comes solely from connectOpenAi.

Timeline

  1. On @stream-io/[email protected] → code 42.
  2. Support (previous ticket) said bump to 0.4.2; the ticket was closed.
  3. Bumped to 0.4.2 → still code 42, model set or unset.

Checks performed (ruling out my side)

  • API key is loaded in the route: confirmed sk-proj-36XU_..., not undefined.
  • Account: paid tier with credit.
  • Model: default gpt-realtime (GA).
  • Agent user: upserted via stream.upsertUsers([...]) at meeting creation, so the agentUserId exists as a Stream user on the call.

Decisive test: same key connects to OpenAI directly

I connected to OpenAI's GA Realtime API directly with the exact same OPENAI_API_KEY:

new WebSocket("wss://api.openai.com/v1/realtime?model=gpt-realtime", {
  headers: { Authorization: `Bearer ${OPENAI_API_KEY}` }
});

Result: WebSocket opens cleanly, no error. So the key, its Realtime access, org verification, and tier are all confirmed working outside Stream.

Conclusion

This concluded that my OpenAI credentials/access were not the problem. Should probably be coming from Stream's connect_agent backend.

Error

⨯ Error: Stream connect_agent failed (code 42): Error:  code
    at ignore-listed frames {
  type: 'error',
  error: {
    type: 'server_error',
    code: '42',
    message: 'Error:  code ',
    param: null,
    event_id: ''
  }
}
 POST /api/webhook/stream 500 in 2.0s (next.js: 121ms, proxy.ts: 11ms, application-code: 1886ms)
 POST /api/webhook/stream 200 in 514ms (next.js: 4ms, proxy.ts: 9ms, application-code: 501ms)
 ......
⨯ Error: Stream connect_agent failed (code 42): Error:  code
    at ignore-listed frames {
  type: 'error',
  error: {
    type: 'server_error',
    code: '42',
    message: 'Error:  code ',
    param: null,
    event_id: ''
  }
}
Vorherrschende Sprache
TypeScript
Sterne
19
Forks
3
Ø Merge
1 T. 5 Std.
Gemergte PRs (30 T.)
11

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus GetStream/stream-node

Alle Issues in GetStream/stream-node

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.