I've been having trouble establishing a WebRTC session and am trying to simplify the issue as much as possible. So I've written up a simple copy & paste example, where you just paste the offer/answer into webforms and click submit.
The HTML+JS, all in one file, can be found here: http://ift.tt/1Awr7XX
I'm on a local network, and am therefore removing the ICE server initialisation process to make this example as bare-bones as possible.
Here are the steps I'm carrying out in the example:
Page 1
Page 1 (loads page), enters a channel name (e.g.
test) and clickscreate.A new
Hostobject is created,new PeerConnection()andcreateDataChannelare called.createOfferis called, and the resultingofferSDPis pasted into theoffertextarea.
Page 2
Copy
offerSDPfrom Page 1 and paste into offer textarea on Page 2, clickjoin.New
Guestobject is created,PeerConnectionand anondatachannelhandler is set.setRemoteDescriptionis called for theGuestobject, with theofferSDPdata.createAnsweris called and the result is pasted into theanswertextarea box.
Page 1
The
answerSDPis copied from Page 2 and pasted into theanswertextarea of Page 1,submit answeris clicked.Host.setRemoteDescriptionis called with theanswerSDPdata. This creates aSessionDescription, thenpeer.setRemoteDescriptionis called with the resulting data.
Those are the steps carried out in the example, but it seems I'm missing something critical. After the offerer's remoteDescription is set with the answerSDP, I try to send a test message on the dataChannel:
Chrome 40
"-- complete"
> host.dataChannel.send('hello world');
VM1387:2 Uncaught DOMException: Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open'
Firefox 35
"-- complete"
ICE failed, see about:webrtc for more details
> host.dataChannel.send('hello world');
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
I also had a more complicated demo operating, with a WebSocket signalling server, and ICE candidates listed, but was getting the same error. So I hope this simplification can help to track down the issue.
Again, the single-file code link: http://ift.tt/1Awr7XX
Aucun commentaire:
Enregistrer un commentaire