我遵循了这个例子:https://github.com/pion/example-webrtc-applications/tree/master/sfu-ws
-
on local is working
-
我做了一个linux构建,我把它放在服务器上,正在工作
-
我把它放在一个docker容器中,它不再工作了。
在docker上我打开了端口范围:
-
50000 - 50200:50000 - 50200/udp
version: '3' services: app: image: xxxx container_name: web_preprod ports: - 127.0.0.1:8080:8080 - 127.0.0.1:6060:6060 - 50000-50200:50000-50200/udp restart: on-failure networks: - xxxx nginx: image: nginx:latest restart: always container_name: nginx_preprod command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'" ports: - "80:80" - "443:443" - "6061:6061" - "6062:6062" networks: - xxxx volumes: - /tmp:/tmp - ./nginx.conf:/etc/nginx/nginx.conf - ./data/certbot/conf:/etc/letsencrypt - ./data/certbot/www:/var/www/certbot depends_on: - app networks: xxxx: driver: bridge
端口6061
不安全,用于测试。
se := webrtc.SettingEngine{}
se.SetEphemeralUDPPortRange(50000, 50200)
WebRTCApi = webrtc.NewAPI(webrtc.WithMediaEngine(getPublisherMediaEngine()), webrtc.WithSettingEngine(se))
但我没有得到onTrack
无论是在服务器或客户端。我看到的是,在服务器上我收到
PeerConnectionStateFailed
我使用google stun,并在客户端免费转服务器
var config = {
iceServers: [{
urls: ["stun:stun1.l.google.com:19302"]
},
{
urls: 'turn:numb.viagenie.ca:3478',
credential: 'xxxx',
username: 'xxxx@gmail.com'
}
]
};
pc = new RTCPeerConnection(config)
如果你有任何想法,我将不胜感激。
问题是Pion(或任何WebRTC实现)只知道它正在侦听的IP地址。它不可能知道映射/转发给它的所有地址。人们也称其为Public IP
或NAT Mapping
。因此,当介子发射它的候选者时,它们可能看起来像10.10.0.*
,而远程对等体将无法联系到它。
你应该做的是使用SettingEngine并设置SetNat1To1IPs。如果您知道主机的公共IP,它将使用公共IP重写候选对象。
ICE是一个棘手的过程。为了从概念上理解它,WebRTC对好奇的#网络可能会有所帮助。我会确保尽快回答任何后续问题!