DoubangoTelecom / sipml5

The world's first HTML5 SIP client (WebRTC)
BSD 3-Clause "New" or "Revised" License
944 stars 460 forks source link

Calling from web browser takes long time #313

Closed raady07 closed 5 years ago

raady07 commented 6 years ago

I am trying to make calls from browser to a mobile by loggingin through demo page provided. I could login and make the call, but when I dail an audio call it remains 40 seconds in connecting status and then changes to ringing status to make the call. So it takes approx 45 seconds for me to get call to mobile after dailing from browser. Are there any special setting that i need to make the application faster? My internet speed is 7.8Mbps and I am checking this on Chrome browser.

RowdyElectron commented 5 years ago

@raady07 I found this issue with asterisk. If possible/applicable to your situation, please try modifying src/tinyMEDIA/src/tmedia_session_jsep.js the way I did:

tmedia_session_jsep01.onIceCandidate = function (o_event, _This) {
    var This = (tmedia_session_jsep01.mozThis || _This);
    if (!This || !This.o_pc) {
        tsk_utils_log_error("This/PeerConnection is null: unexpected");
        return;
    }
    var iceState = (This.o_pc.iceGatheringState || This.o_pc.iceState);

    tsk_utils_log_info("onIceCandidate = " + iceState);

    if (!tmedia_session_jsep01.ice_timer) {
    tmedia_session_jsep01.ice_timer = setTimeout(function() {
        console.log("ICE timer...");
        tmedia_session_jsep01.onIceGatheringCompleted(This);
        tmedia_session_jsep01.ice_timer = null;
    },2000);
    };

    if (iceState === "complete" || (o_event && !o_event.candidate)) {
        tsk_utils_log_info("ICE GATHERING COMPLETED!");
        tmedia_session_jsep01.onIceGatheringCompleted(This);
    }
    else if (This.o_pc.iceState === "failed") {
        tsk_utils_log_error("Ice state is 'failed'");
        This.o_mgr.callback(tmedia_session_events_e.GET_LO_FAILED, This.e_type);
    }
}
BruceYuj commented 5 years ago

it almost half the time

raady07 commented 5 years ago

Instead of using google ICEservers, I created a local ICE server and the issue is resolved for the moment. I am not sure if it is a permanent solution, but the call connection is faster and getting connected in 3~4 seconds. I had been using this setup since 3 months and there were no problems till now.

BruceYuj commented 5 years ago

I change the code setTimeout(..., 2000) to setTimeout(..., 0). and It become faster@raady07. I don't know why it needs 2000ms ,so I change it to 0 ms, and it works.

majidbigdeli commented 5 years ago

Thank you

manikantagadde commented 5 years ago

40 secs delay occurs because of delay in ICE gatherings, Reasons: Required ports might be blocked on your network or you might be under a VPN. In either of the cases, chrome waits till timeout (default is 40 secs). Decreasing timeout to 0 sec can be dangerous because you are not giving time for ICE negotiation and this might result in one-way audio issues.