我已定制Apprtc项目(Android版)。 假设我们有四个互联网连接(来自不同的网络连接):
NetA
- NetB
NetC
- NetD
我可以从NetA
连接到NetB
,但我无法从NetC
连接到NetD
!
我设置了turn server
和stun server
,但我不知道出了什么问题。
-
从NetA
连接到NetB
(成功)时:
提供SDP:
" v = 0 \ r \ no = - 632333030865012591 2 IN IP4 127.0.0.1 \ r \ ns = - \ r \ nt = 0 0 \ r \ na = group:BUNDLE audio video \ r \ nn na = msid-semantic:WMS ARDAMS ___ \ r \ nm = audio 9 UDP / TLS / RTP / SAVPF 111 103 9 102 0 8 105 13 126 \ r \ nc = IN IP4 0.0.0.0 \ r \ nn = rtcp:9 IN IP4 .............."
"候选人:2580031558 1 udp 2122260223 100.95.184.57 37422 typ host generation 0 ufrag NL4P network-id 3 network-cost 900"
"候选人:411053810 1 udp 1686052607 5.116.182.156 1026 typ srflx raddr 100.95.184.57 rport 37422 generation 0 ufrag NL4P network-id 3 network-cost 900"
"候选人:3902036248 1 udp 41885695 34.197.185.148 52061 typ relay raddr 5.116.182.156 rport 1026 generation 0 ufrag NL4P network-id 3 network-cost 900"
&#34;候选人&#34;:&#34;候选人:2786567656 1 udp 25108223 34.197.185.148 52062 typ relay raddr 5.116.182.156 rport 1032 generation 0 ufrag NL4P network-id 3 network-cost 900&#34; < / p>
回答SDP:
&#34; v = 0 \ r \ no = - 3736097442176838392 2 IN IP4 127.0.0.1 \ r \ ns = - \ r \ nt = 0 0 \ r \ na = group:BUNDLE audio video \ r \ nn na = msid-semantic:WMS ARDAMS ___ \ r \ nm = audio 9 UDP / TLS / RTP / SAVPF 111 103 9 102 0 8 105 13 126 \ r \ nc = IN IP4 0.0.0.0 \ r \ nn = rtcp:9 IN IP4 0.0.0.0 \ r \ NA =冰冷ufrag:7upj \ r \呐............&#34;
&#34;候选人:1892013251 1 udp 2122260223 192.168.7.7 37718 typ host generation 0 ufrag 7upj network-id 3 network-cost 10&#34;
&#34;候选人:3650771734 1 udp 1686052607 151.242.87.74 37718 typ srflx raddr 192.168.7.7 rport 37718 generation 0 ufrag 7upj network-id 3 network-cost 10&#34;
&#34;候选人:3902036248 1 udp 41885695 34.197.185.148 52063 typ relay raddr 151.242.87.74 rport 37718 generation 0 ufrag 7upj network-id 3 network-cost 10&#34;
&#34;候选人&#34;:&#34;候选人:2786567656 1 udp 25108223 34.197.185.148 52064 typ relay raddr 151.242.87.74 rport 45889 generation 0 ufrag 7upj network-id 3 network-cost 10&#34; < / p>
-
从NetC
连接到NetD
(失败)时:
提供SDP:
&#34; v = 0 \ r \ no = - 280763199112942253 2 IN IP4 127.0.0.1 \ r \ ns = - \ r \ nt = 0 0 \ r \ na = group:BUNDLE audio video \ r \ nn na = msid-semantic:WMS ARDAMS ___ \ r \ nm = audio 9 UDP / TLS / RTP / SAVPF 111 103 9 102 0 8 105 13 126 \ r \ nc = IN IP4 0.0.0.0 \ r \ nn = rtcp:9 IN IP4 0.0.0.0 \ r \ NA =冰冷ufrag:UPpi \ r \ NA =冰冷PWD:Ow2J0AHuS86I0o0yZ5MOv6a / \ r \ NA =冰冷选项:再提名\ r \ NA =指纹:SHA-256 ...... ...........&#34;
&#34;候选人&#34;:&#34;候选人:2580031558 1 udp 2122260223 100.95.184.57 34267 typ host generation 0 ufrag UPpi network-id 3 network-cost 900&#34;
&#34;候选人&#34;:&#34;候选人:411053810 1 udp 1686052607 5.116.182.156 1287 typ srflx raddr 100.95.184.57 rport 34267 generation 0 ufrag UPpi network-id 3 network-cost 900&#34; < / p>
&#34;候选人&#34;:&#34;候选人:3902036248 1 udp 41885695 34.197.185.148 58779 typ relay raddr 5.116.182.156 rport 1287 generation 0 ufrag UPpi network-id 3 network-cost 900&#34; < / p>
&#34;候选人&#34;:&#34;候选人:2786567656 1 udp 25108223 34.197.185.148 58780 typ relay raddr 5.116.182.156 rport 1201 generation 0 ufrag UPpi network-id 3 network-cost 900&#34; < / p>
回答SDP:
&#34; v = 0 \ r \ no = - 6478139475592243492 2 IN IP4 127.0.0.1 \ r \ ns = - \ r \ nt = 0 0 \ r \ na = group:BUNDLE audio video \ r \ nn na = msid-semantic:WMS ARDAMS ___ \ r \ nm = audio 9 UDP / TLS / RTP / SAVPF 111 103 9 102 0 8 105 13 126 \ r \ nc = IN IP4 0.0.0.0 \ r \ nn = rtcp:9 IN IP4 0.0.0.0 \ r \ nn = ice-ufrag:Js6x \ r \ n = na-ice-pwd:5tyUT023mAERirumK7aal + 9F \ r \ nn = na-ice-options:renomination \ r \ na = fingerprint:sha-256 45:97:7F :BC:37:90:4D:B6:35:E5:23:C8:12:09:5A:43:D7:4B:03:EC:A0:7B:70:EB:E4:DB:12:B8 :7B:1C:6E:5D \ r \ NA =设置:活性..............&#34;
&#34;候选&#34;&#34;标签&#34;:0,&#34; ID&#34;:&#34;音频&#34;&#34;候选&#34 ;: &#34;候选人:1106113138 1 udp 2122260223 192.168.1.169 44238 typ host generation 0 ufrag Js6x network-id 3 network-cost 10&#34;
&#34;候选人&#34;:&#34;候选人:3232101574 1 udp 1686052607 151.247.139.59 44238 typ srflx raddr 192.168.1.169 rport 44238 generation 0 ufrag Js6x network-id 3 network-cost 10&#34; < / p>
&#34;候选人&#34;:&#34;候选人:3902036248 1 udp 41885695 34.197.185.148 58781 typ relay raddr 151.247.139.59 rport 44238 generation 0 ufrag Js6x network-id 3 network-cost 10&#34; < / p>
&#34;候选人&#34;:&#34;候选人:2786567656 1 udp 25108223 34.197.185.148 58782 typ relay raddr 151.247.139.59 rport 36519 generation 0 ufrag Js6x network-id 3 network-cost 10&#34; < / p>
&#34;候选人&#34;:&#34;候选人:238873586 1 udp 2122194687 100.116.182.76 48966 typ host generation 0 ufrag Js6x network-id 4 network-cost 900&#34;
&#34;候选人&#34;:&#34;候选人:3266434145 1 udp 1685987071 91.251.147.158 16369 typ srflx raddr 100.116.182.76 rport 48966 generation 0 ufrag Js6x network-id 4 network-cost 900&#34; < / p>
&#34;候选人&#34;:&#34;候选人:3902036248 1 udp 41820159 34.197.185.148 58783 typ relay raddr 91.251.147.158 rport 16369 generation 0 ufrag Js6x network-id 4 network-cost 900&#34; < / p>
&#34;候选人&#34;:&#34;候选人:2786567656 1 udp 25042687 34.197.185.148 58784 typ relay raddr 91.251.147.158 rport 16222 generation 0 ufrag Js6x network-id 4 network-cost 900&#34; < / p>
编辑:
感谢所有人。我发现我的问题来自我的转机服务器。在使用appr.tc冰服务器(谷歌转服务器)时,我可以在任何情况下连接。但是我无法与我的转弯服务器连接。请在此页面查看有关我的转弯服务器的问题:
答案 0 :(得分:1)
看一下这篇文章Introduction to WebRTC protocols。
您需要设置STUN和TURN服务器,以通过防火墙。如果peer位于防火墙或路由器后面,通过仅连接到IP地址,您将点击路由器而不是请求的对等设备。等等。
答案 1 :(得分:1)
如果真的有效,我会开始测试我的TURN服务器。 禁用防火墙上的直接链接(在NetC和NetD之间或仅阻止对等IP)以查看它是否通过TURN工作。如果没有,请修复您的TURN服务器或其配置。