SIP.js icon indicating copy to clipboard operation
SIP.js copied to clipboard

Suggestion - Error event when SIP Server is down

Open brunogsa opened this issue 11 years ago • 4 comments

Hey there!

We're trying to do something like a recovering system, which must be triggered when our SIP Server is down.

Currently, when we try to start() our User Agent, the last event being triggered is the "connecting". SIP debug messages, however, already shows that we have an error "ECONNREFUSED", since our SIP Server is down, so we were expecting an error event to be triggered - maybe the "disconnected" event.

What happens when SIP Server is up and running:

sipjs-ok-scenario

sipjs-ok-scenario-2

What happens when SIP Server is down:

sipjs-connecting-1

sipjs-connecting-2

Our code:

        // SIP Event Handlers
        sipUA.on('connecting', onConnecting);
        sipUA.on('connected', onConnected);
        sipUA.on('disconnected', onDisconnected);
        sipUA.on('registered', onRegistered);
        sipUA.on('unregistered', onUnregistered);
        sipUA.on('registrationFailed', onRegistrationFailed);
        sipUA.on('invite', onInvite);
        sipUA.on('message', onMessage);

        Logger.debug('[createSipUA] Added SIP event listeners to UA');

(...)

    function onConnecting(args) {
        Logger.debug('SIP UA connecting..');
    }

    function onConnected() {
        Logger.debug('SIP UA connected');
        registerSipUA();
    }

    function onDisconnected() {
        Logger.fatal('SIP UA disconnected');
    }

    function onRegistered() {
        Logger.info('SIP UA is probably registered now');
    }

    function onUnregistered(cause) {
        Logger.warn('SIP UA was unregistered:\n\t' + cause);
    }

    function onRegistrationFailed(cause) {
        Logger.fatal('SIP UA registration failed:\n\t' + cause);
    }

brunogsa avatar Aug 26 '15 14:08 brunogsa

Maybe related to #217 ?

matthieusieben avatar Aug 31 '15 10:08 matthieusieben

Hrm. I would have expected that to have some sort of error event propagate up. I know this ticket is a little stale at this point (sorry!). Is the issue still happening? I'll see if I can't reproduce it.

wakamoleguy avatar Oct 16 '15 18:10 wakamoleguy

Yeah, it's still happening! For now I'm using the workaround proposed on #217!

brunogsa avatar Nov 03 '15 19:11 brunogsa

Related to this: the 0.11.0 release contains a major refactor to the transport code. Included in these changes is a transportError event that is emitted by the Transport. I'm going to close this for now, but if the behavior of the event isn't quite what you'd expected I think it'd be appropriate to just open a new discussion (seeing as this one is a few years old) or even a PR.

JimGreenberg avatar Jun 25 '18 15:06 JimGreenberg