【发布时间】:2019-08-06 11:20:20
【问题描述】:
大家!我正在尝试使用 nodejs 学习 javascript 和 webrtc。我在此链接https://codelabs.developers.google.com/codelabs/webrtc-web/#6 中遵循谷歌代码实验室的教程。源代码在这里https://github.com/googlecodelabs/webrtc-web/tree/master/step-05。一切都很好,但现在我想尝试看看它是否可以在互联网上运行。我学会了在 Heroku 上部署网络。 https://simple-videochat-test.herokuapp.com/。但是我收到了这个错误:
Access to XMLHttpRequest at 'https://computeengineondemand.appspot.com/turn?username=41784574&key=4080218913' from origin 'https://simple-videochat-test.herokuapp.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
我检查了一下,发现服务器不再工作了。因此,我尝试将此代码中当前为 apprtc 工作的另一个转向服务器添加到 main.js 文件中:
var pcConfig = {
'iceServers': [
{
'urls': 'stun:stun.l.google.com:19302'
},
{
'urls': 'turn:192.158.29.39:3478?transport=udp',
'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
'username': '28224511:1379330808'
},
{
'urls': 'turn:192.158.29.39:3478?transport=tcp',
'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
'username': '28224511:1379330808'
}
]
};
nodejs 的 package.json 如下:
{
"name": "webrtc-codelab",
"version": "0.0.1",
"description": "WebRTC codelab",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"node-static": "^0.7.10",
"socket.io": "^2.0.4"
}
}
我可以看到客户端收到来自对方的消息,但没有视频显示。有人能帮我一下吗?对不起,如果我的英语不好。我不是母语人士。谢谢
【问题讨论】:
-
你可以从基础开始。以前我试过shanetully.com/2014/09/a-dead-simple-webrtc-example,这真的很好用。
-
@Austin 谢谢,我去看看。
标签: javascript webrtc