鱼儿慢慢游~~

导航

 

最近在做webrtc相关的内容,底层ice协商遇到如下问题:

libnice版本:0.1.14  获取地址:https://nice.freedesktop.org/releases/

单nat的情况:

1. 当浏览器(标准webrtc实现)位于nat内,服务器(使用libnice)位于公网时,可以实现ice的成功协商,获取协商的端口。

2. 当浏览器位于公网,服务器位于nat内时,服务器的ice协商迟迟不能成功。

抓包显示:

其中10.1.1.226为nat内地址,10.9.9.105为服务器地址。

226发出binding request请求后,在105回复的response请求中携带了其映射的地址:172.16.193.176

icerfc:  https://tools.ietf.org/html/rfc5245 标准中有如下一段话:

 

即,在binding response消息中会携带客户端映射的外网地址。

 

客户端收到bind response信息中的映射地址后,需要把该地址当做新的candidate,来协商

因此按照规范定义,在这种情况下应该是可以协商通过的,但是libnice并没有。

查阅google:

https://github.com/meetecho/janus-gateway/issues/788

 有兴趣的可以读完整个讨论,这里摘录开头

Not sure if this is anything you want to look into now, but I thought I'd file it in case. 
Current master of libnice (1778f79008 as of this writing) doesn't seem to work properly with Janus.
I am currently using the latest libnice with a Licode installation I have, so I don't think the issue is only with libnice. Some git bisect work got me to the problem commit: 1ab9d7c104978ea1904aaaad708c1c8c23c77592 is the first bad commit commit 1ab9d7c104978ea1904aaaad708c1c8c23c77592 Author: Olivier Crête olivier.crete@collabora.com Date: Thu May 26 16:05:36 2016 -0400 conncheck: Separate valid and succeded states RFC 5245 specifies that when a mapped-address differs from the address from the request was sent, the mapped-address is used to select the valid pair, but the source address of the check is used to select the pair that succeeded, so they are not the same. After reverting that commit (took a small amount of conflict resolution, but not too bad),
I was able to get libnice master working again with Janus. Normally I wouldn't expect you to chase the master commits,
but libnice is a unique beast -- the last official release was almost two years ago,
and it has issues that have long since been fixed in master.
I thought it might be worth looking at this problem commit that
I found to see if there's some reasonable adjustment you can make in Janus to accommodate for it.
with libnice master, ice fails when client in NAT。

因此怀疑是libnice的版本问题,在github上master分支拉取最新代码编译后,问题解决。

 

posted on 2018-12-27 10:24  miss_UU  阅读(2065)  评论(0编辑  收藏  举报