WEBRTC配置安装

WEBRTC配置安装

免费stun服务器
stun.ekiga.net
nat type: Symmetric
local end: 0.0.0.0:63012
public end: 117.159.6.115:46304

stun.schlund.de
117.159.6.115:32896

117.159.6.115

[root@localhost ~]# firewall-cmd --zone=public --add-port=5350/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# systemctl restart firewalld

turnserver -o -v -f -a -m 2 --max-bps=100000 --min-port=32355 --max-port=65535 --user=phz:1 -r phzled.cn -L 192.168.1.66

turnserver -o -f -v -a -m 2 --max-bps=100000 --min-port=32355 --max-port=65535 --user=phz:1 -r phzled.cn -X 117.159.6.115/192.168.1.66 -X 117.159.6.115/192.168.1.66

turnserver --no-auth --stun-only -v
turnserver -v --user=zjf:1 --realm apprtc --no-stun
stun/turn服务同时开启:turnserver -v --user=zjf:1 --realm apprtc
/sbin/iptables -I INPUT -p tcp --dport 3478 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 3479 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 5349 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 5350 -j ACCEPT

config={"iceServers":[{"urls":["turn:192.168.1.66"],"username":"zjf","credential":"1"}],"iceTransportPolicy":"all","iceCandidatePoolSize":"0"}
config={"iceServers":[{"urls":["stun:192.168.1.66"],"username":"","credential":""}],"iceTransportPolicy":"all","iceCandidatePoolSize":"0"}
config={"iceServers":[{"urls":["turn:192.168.1.66"],"username":"zjf","credential":"1"},{"urls":["stun:192.168.1.66"],"username":"","credential":""}],"iceTransportPolicy":"all","iceCandidatePoolSize":"0"}

建立连接的日志:
第一步:创建本机的PeerConnection
Created local peer connection object localConnection
main.js:50 Created send data channel
main.js:66 Created remote peer connection object remoteConnection
第而不:获得本机的媒体信息sdp,为了向对方发offer
main.js:113 Offer from localConnection
v=0
o=- 6842214109041335097 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:b7Wc
a=ice-pwd:PubgL1+G4v2+/YtZIG51WQJs
a=ice-options:trickle
a=fingerprint:sha-256 B4:F5:75:B7:C7:09:49:E1:AF:8C:80:B5:C4:5E:BD:90:10:C1:72:AA:D4:E1:A8:75:94:19:02:BF:6A:BC:12:45
a=setup:actpass
a=mid:0
a=sctp-port:5000
a=max-message-size:262144

第三步:对端收到offer后,携带自己的sdp进行应答answer
main.js:122 Answer from remoteConnection
v=0
o=- 2820179291816102784 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:bx6n
a=ice-pwd:pS0bo2Hys8gwD724KI5FTcW2
a=ice-options:trickle
a=fingerprint:sha-256 14:DA:D8:33:82:6E:B8:05:3F:17:58:6F:2E:FC:74:2C:8A:DE:5F:61:90:11:FF:31:76:DF:24:A8:21:93:B5:4E
a=setup:active
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
----------媒体信息交换完成,走完协商第一步,开始交换网络信息--------------
第四步:从ice服务器获得公网ip,发送给对端peer,
main.js:140 remotePeerConnection ICE candidate: candidate:1613033416 1 udp 2113937151 c83d25f9-2ef3-43af-b124-18e2be66ce56.local 54362 typ host generation 0 ufrag bx6n network-cost 999
main.js:140 localPeerConnection ICE candidate: candidate:1613033416 1 udp 2113937151 c83d25f9-2ef3-43af-b124-18e2be66ce56.local 54360 typ host generation 0 ufrag b7Wc network-cost 999
2main.js:148 AddIceCandidate success.
main.js:170 Send channel state is: open
main.js:156 Receive Channel Callback
main.js:185 Receive channel state is: open
main.js:140 localPeerConnection ICE candidate: candidate:2992052952 1 udp 33562367 192.168.1.66 59877 typ relay raddr 192.168.1.233 rport 54360 generation 0 ufrag b7Wc network-cost 999
main.js:140 localPeerConnection ICE candidate: (null)
main.js:148 AddIceCandidate success.
main.js:140 remotePeerConnection ICE candidate: candidate:2992052952 1 udp 33562367 192.168.1.66 51287 typ relay raddr 192.168.1.233 rport 54362 generation 0 ufrag bx6n network-cost 999
main.js:140 remotePeerConnection ICE candidate: (null)
3main.js:148 AddIceCandidate success.
-----------网络信息交换完成---------------------------------

参考
https://www.jianshu.com/p/43957ee18f1a
https://www.jianshu.com/p/915eab39476d
http://www.51testing.com/html/89/n-3720989.html

posted @ 2020-08-31 22:01  windlog  阅读(658)  评论(0编辑  收藏  举报