admin管理员组文章数量:1182280
I’m working on a WebRTC-based real-time application where the frontend (browser) connects to OpenAI’s Realtime API via a signaling server hosted on Cloudflare Workers. The project uses the following Cloudflare Workers sample code for the signaling server:
The application works locally on localhost but fails in production when deployed to Cloudflare Workers. It seems it can't initiate the peer connection and it moves to a failed
state. Retry to connect also doesn't work.
- Frontend (browser) generates an SDP offer and sends it to the /rtc-connect endpoint on the Worker.
peerConnection = new RTCPeerConnection();
dataChannel = peerConnection.createDataChannel('response');
peerConnection.createOffer().then((offer) => {
peerConnection.setLocalDescription(offer);
fetch('/rtc-connect', {
method: 'POST',
body: offer.sdp,
headers: {
'Content-Type': 'application/sdp',
},
})
.then((r) => r.text())
.then((answer) => {
peerConnection.setRemoteDescription({
sdp: answer,
type: 'answer',
});
})
.catch((error) => console.error("Error in signaling:", error));
});
本文标签: WebRTC Connection Fails with OpenAI Realtime API in ProductionStack Overflow
版权声明:本文标题:WebRTC Connection Fails with OpenAI Realtime API in Production - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738280672a2072707.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论