问题描述
I'm trying to launch this on AWS Ubuntu。
它在本地主机上的 Chrome 下运行良好。 (Firefox 有一个问题,希望使用 HTTPS 远程运行会使问题消失。但这与此问题无关。)
我使用 AWS 控制台打开了 readme.MD 上指定的端口(入站 TCP 到端口 3000,入站 UDP 到端口 40000-49999,允许所有出站流量。)
module.exports = {
// http server ip,port,and peer timeout constant
//
httpIp: "0.0.0.0",httpPort: 3000,httpPeerStale: 15000,// ssl certs. we'll start as http instead of https if we don't have
// these
sslCrt: "local.crt",sslKey: "local.key",mediasoup: {
worker: {
rtcMinPort: 40000,rtcMaxPort: 49999,logLevel: "debug",logTags: [
"info","ice","dtls","rtp","srtp","rtcp",// 'rtx',// 'bwe',// 'score',// 'simulcast',// 'svc'
],},router: {
mediaCodecs: [
{
kind: "audio",mimeType: "audio/opus",clockRate: 48000,channels: 2,{
kind: "video",mimeType: "video/VP8",clockRate: 90000,parameters: {
// 'x-google-start-bitrate': 1000
},mimeType: "video/h264",parameters: {
"packetization-mode": 1,"profile-level-id": "4d0032","level-asymmetry-allowed": 1,// 'x-google-start-bitrate' : 1000
},"profile-level-id": "42e01f",],// rtp listenIps are the most important thing,below. you'll need
// to set these appropriately for your network for the demo to
// run anywhere but on localhost
webRtcTransport: {
listenIps: [
{ ip: "172.3.-.-",announcedIp: "18.255.8.87" },// { ip: "192.168.42.68",announcedIp: null },// { ip: '10.10.23.101',initialAvailableOutgoingBitrate: 800000,};
使用我在 AWS 控制台上找到的值: (不能复制/粘贴这个)
订阅视频无法正常工作,如下所示: (不能复制/粘贴这个)
(过了一会儿 Chrome 的控制台显示 mediasoup-client:Transport connection state changed to disconnected +17s
)
在我看来好像我需要打开一两个额外的端口,但我不确定是哪个。
我将非常感谢您的帮助。提前谢谢你... :)
解决方法
这是怎么回事?
listenIps: [
{ ip: "172.3.-.-",announcedIp: "18.255.8.87" },
尝试将您的 EC2 的公共 IP 放在 ip
中,并将 announcedIp
设置为 null。
或者,做我所做的here,因为我厌倦了摆弄 config.js 设置。
function getListenIps () {
const listenIps = []
if (typeof window === 'undefined') {
const os = require('os')
const networkInterfaces = os.networkInterfaces()
const ips = []
if (networkInterfaces) {
for (const [key,addresses] of Object.entries(networkInterfaces)) {
addresses.forEach(address => {
if (address.family === 'IPv4') {
listenIps.push({ ip: address.address,announcedIp: null })
}
/* ignore link-local and other special ipv6 addresses.
* https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
*/
else if (address.family === 'IPv6'
&& address.address[0] !== 'f') {
listenIps.push({ ip: address.address,announcedIp: null })
}
})
}
}
}
if (listenIps.length === 0) {
listenIps.push({ ip: '127.0.0.1',announcedIp: null })
}
return listenIps
}
并且,请注意 WebRTC 可以在 mediasoup 网络服务器端口以外的端口上与 TLS 连接。
,我遇到了同样的问题,以下事情帮助我让它工作:
1.) 确保在用于 EC2 实例的安全组和操作系统的防火墙(在Ubuntu 的情况是 ufw)。要在 ubuntu 上启用端口,您可以使用 sudo ufw allow 4000:4999/udp
。
2.) 对于 listenIps,使用 [{ ip: "0.0.0.0",announcedIp: process.env.ANNOUNCED_IP }]
其中 ANNOUNCED_IP 环境变量等于 EC2 实例的公共 IPV4 地址。