libnice的問題記錄

最近在作webrtc相關的內容,底層ice協商遇到以下問題:html

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

單nat的狀況:github

1. 當瀏覽器(標準webrtc實現)位於nat內,服務器(使用libnice)位於公網時,能夠實現ice的成功協商,獲取協商的端口。web

2. 當瀏覽器位於公網,服務器位於nat內時,服務器的ice協商遲遲不能成功。瀏覽器

抓包顯示:服務器

其中10.1.1.226爲nat內地址,10.9.9.105爲服務器地址。app

226發出binding request請求後,在105回覆的response請求中攜帶了其映射的地址:172.16.193.176this

icerfc:  https://tools.ietf.org/html/rfc5245 標準中有以下一段話:google

 

即,在binding response消息中會攜帶客戶端映射的外網地址。spa

 

客戶端收到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分支拉取最新代碼編譯後,問題解決。

相關文章
相關標籤/搜索