2013-01-11 22 views
0

我試圖在最新的Chrome Canary(dataChannel標誌爲打開)中創建數據通道。webRTC createDataChannel在Chrome Canary中拋出DOM異常

var SERVER = "stun:stun.l.google.com:19302"; 
var pc1 = new window.webkitRTCPeerConnection({"iceServers": [{"url": SERVER}]}); 
pc1.createDataChannel('my_channel'); 

金絲雀我拋出以下異常:NotSupportedError:DOM異常9

有誰知道這是爲什麼發生?

+1

使用優惠/答案模型來交換SDP/ICE ....請參閱:https://webrtc-experiment.appspot.com/docs/how-to-use- rtcdatachannel.html ....或演示聊天:https://webrtc-experiment.appspot.com/chat/ –

回答

0

Chrome需要一些連接約束條件才能設置爲true。更具體地說,「RtpDataChannels」約束是重要的。嘗試使用它:

configuration = {'iceServers': [{'url': 'stun:stun.l.google.com:19302'}]}; 
connection = { 'optional': [{'DtlsSrtpKeyAgreement': true}, {'RtpDataChannels': true }] }; 
pc1 = new window.webkitRTCPeerConnection(configuration,connection); 
pc1.createDataChannel('my_channel');