connectOpenAi fails with `server_error code 42` on 0.4.2
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- node.js, typescript
- 领域
- api, audio-video-rtc, backend
调研方向
从 TypeScript 的 connectOpenAi 调用开始,使用列出的 SDK 版本跟踪其请求到 Stream 的 /video/connect_agent 端点。使用提供的 webhook 流程复现,并将传播出的 code 42 错误与直接的 OpenAI Realtime 连接进行比较。完成标准是:同一个有效密钥可以在没有不透明服务器错误的情况下,将 agent 连接到 Stream Video 通话。
由索引模型根据 Issue 内容生成。
描述
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
- On @stream-io/openai-realtime-api@0.4.0 → code 42.
- Support (previous ticket) said bump to 0.4.2; the ticket was closed.
- 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: ''
}
}
- 主要语言
- TypeScript
- 星标
- 19
- 派生
- 3
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 11
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GetStream/stream-node 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
GetStream/stream-node#132 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
GetStream/stream-node#2 ·
查看 GetStream/stream-node 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug v2
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/inspector#2458 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
难度 2/5 1-3 小时 新手友好度 70/100
carbon-design-system/ibm-products#9907 ·