Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onicecandidate event is firing before acceping the answer

I am haveing trouble in runing my own webrtc demo code in chrome browser v30. But the code is perfectly working on firefox. onicecandidate event is firing before the offer is accepted by the other peer. on the other side peer connection is only created after the offer is accepted. due to this when onicecandidate is fired, on the receiving side ending in peer connection null error. As far as I understand the WebRTC and flow of my code is
step 1 : caller press the call button
step 2 : getUsermedia will be called
step 3 : peer connection will be created
step 4 : offer will be sent to caller
step 5 : offer will be displayed to caller
step 6 : peer connection is only created after the caller accepts the call
step 7 : peer connection will create the answer
step 8 : answer sent to caller
step 9 : caller will send the icecandidates to callee
step 10 : callee will send the icecandidates to caller

The problem with the above flow is that on the callee side peer connection is only created after the user accepts the offer. But in the caller side just after the offer is created and before offer is accepted, ice candidate are being sent to caller. caller side this is result in null error.

I pasted debuging log in pastebin :- pastebinDOTcom/gMgaxbBp

Please provide me a solution for this problem.

like image 945
cJ_ Avatar asked Mar 21 '23 15:03

cJ_


1 Answers

I figured it out my self. problem is actually in chrome as soon as the peer connection local description is set, it will start ice gathering. we need to forward these ice candidate only after the offer/answer is complete. util it we need to store in locally in some way. The reason for this code perfectly working on firefox is In firefox the icecandidates will be gathered and placed in offer itself. so icecandidate are exchanged on offer/answer itself.

like image 102
cJ_ Avatar answered Apr 06 '23 11:04

cJ_