Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatheringTimeout Missing v3.x #432

Closed
svarunan opened this issue Mar 24, 2017 · 11 comments
Closed

gatheringTimeout Missing v3.x #432

svarunan opened this issue Mar 24, 2017 · 11 comments

Comments

@svarunan
Copy link

Hi
This not a bug but a specific feature missed out while moving to adapter.js
We updated our JsSIP version to v3.0.0 everything works as expected but not 'gatheringTimeout'.

  1. Default ICE Timeout behaviour is 10 sec. But incases when customer's Firewall blocks stun port or in slow network it causes initial outbound invite to get delayed by 10 sec.
  2. Currently i've done a work around in
connection.setLocalDescription(desc)
    .then(function() {
        if (connection.iceGatheringState != 'complete') {
            setTimeout(function() {
                if (connection.iceGatheringState === 'complete') {
                    return;
                }
                console.log('Timeout for ICE gathering after 2000');
                self.rtcReady = true;
                if (onSuccess) {
                    var e = {
                        originator: 'local',
                        type: type,
                        sdp: connection.localDescription.sdp
                    };
                    self.emit('sdp', e);
                    onSuccess(e.sdp);
                    onSuccess = null;
                }
            }, 2000)
        }
        console.log('iceGatheringState', connection.iceGatheringState)
    })
    .catch(function(error) {
          self.rtcReady = true;
          if (onFailure) {
              onFailure(error);
          }
          self.emit('peerconnection:setlocaldescriptionfailed', error);
    });
  1. If will be good if gatheringTimeout is added back so users can pass it via pcConfig
@ibc
Copy link
Member

ibc commented Apr 14, 2017

We don't want to make or maintain WebRTC workarounds. My personal goal would be to completely decouple JsSIP from the WebRTC/PeerConnection stuff, by providing an API that lets the application join both (see #427).

I will let this issue open for now. If it takes too long before we do #427, we may add a setting for this need.

@sasi-plivo
Copy link

@ibc any milestone set on #427 ?

@ibc
Copy link
Member

ibc commented Jun 15, 2017

It will be done when we get time for it within our professional priorities. Money would help prioritizing it.

@tungnt1988
Copy link

anything update for this issue?

  • Svarunan's solution caused the call to fail
  • If not timeout, emit 'sdp' is very long
    --- chrome log --
    JsSIP:RTCSession new +0ms
    JsSIP:RTCSession connect() +1ms
    JsSIP:RTCSession emit "peerconnection" +6ms
    JsSIP:RTCSession newRTCSession() +0ms
    JsSIP:RTCSession session connecting +42ms
    JsSIP:RTCSession emit "connecting" +0ms
    JsSIP:RTCSession createLocalDescription() +1ms
    JsSIP:RTCSession emit "sdp" +40s
    JsSIP:RTCSession emit "sending" [request:InitialOutgoingInviteRequest {ua: UA, headers: {…}, method: "INVITE", ruri: URI, body: "v=0
    JsSIP:Transport send() +1m

@Pechenn
Copy link

Pechenn commented Mar 14, 2018

as i updated to 3.2.5 so i made patch like this:

`
// Add 'pc.onicencandidate' event handler to resolve on last candidate.
return new Promise((resolve) =>
{
let listener;

      connection.addEventListener('icecandidate', listener = (event) =>
      {
        const that = this;

        setTimeout(function()
        {
          if (connection.iceGatheringState === 'complete')
          {
            return;
          }
          debug('ICE Timeout reached!');
          connection.removeEventListener('icecandidate', listener);
          that._rtcReady = true;

          const e = { originator: 'local', type: type, sdp: connection.localDescription.sdp };

          debug('emit "sdp"');

          that.emit('sdp', e);

          resolve(e.sdp);

        }, 2000);

        const candidate = event.candidate;

        if (! candidate)
        {
          connection.removeEventListener('icecandidate', listener);
          this._rtcReady = true;

          const e = { originator: 'local', type: type, sdp: connection.localDescription.sdp };

          debug('emit "sdp"');

          this.emit('sdp', e);

          resolve(e.sdp);
        }
      });
    });

`

@jmillan
Copy link
Member

jmillan commented Mar 22, 2018

There is a new RTCSession event: icecandidate, which provides a mechanism to skip the remaining local ICE gathering process whenever you like.

Whenever you are about to make an outgoing call or answer an incoming call, set the event at your will and tell the Session within the event handler whether you have enough candidates by executing the ready function that is provided to the event callback function.

NOTE: If you don't need the same behaviour for the whole session, do register/unregister the event handler from the event conveniently.

@jmillan jmillan closed this as completed Mar 22, 2018
lei40251 pushed a commit to lei40251/JsSIP that referenced this issue Feb 20, 2019
@themodernpk
Copy link

@jmillan can you please provide sample code to icecandidate to skip the remaining local ICE gathering process.

@ibc
Copy link
Member

ibc commented Jul 1, 2019

Sorry, how to do it is documented in the API. You must rely on the API and not on code snippets.

@themodernpk
Copy link

themodernpk commented Jul 1, 2019

@ibc totally understand that. I have tried to understand API, but could not figure out how to use it. I have been using https://sipjs.com/api/0.7.0/ua_configuration_parameters/ and it had straight forward setting iceCheckingTimeout.

@ibc
Copy link
Member

ibc commented Jul 1, 2019

Honestly I don't care how sipjs does it. We expose an API for it and it works if property used.

@themodernpk
Copy link

@ibc okay, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants