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

Event Message

Open Djcd opened this issue 12 years ago • 4 comments

I don't know if this is a bug.

I use the Kamailio Sip Server and need to add a callback for message events before the SIP-REGISTER:

var test = function(message) {
    console.log('Got message');
};
userAgent.on('message', test);

var callback = function(e) {
    console.log('Got register');
};
userAgent.once('registered', callback);
userAgent.register();

When we switch these events now

var callback = function(e) {
    console.log('Got register');
};

userAgent.once('registered', callback);
userAgent.register();

var test = function(message) {
    console.log('Got message');
};
userAgent.on('message', test);

the Register does not contain the Allow: MESSAGE and Kamailio skips the Message until a new Register is send to the server. Therefore all messages between userAgent.on('message', test); and the reregister are lost.

Greetings Djcd

Djcd avatar Apr 29 '14 12:04 Djcd

Hi Djcd,

That's a good question. It certainly behaves that way intentionally. For invite and message events, the UA dynamically adds those to the Allow header depending on whether there is an event listener defined. That behavior makes some sense to me, although I would open to convincing otherwise. It's worth noting that the Allow header is put on every request, not just REGISTER requests, so it's best to define those listeners early.

Is that behavior from Kamailio configurable? We are mostly an OpenSIPS shop here. I haven't seen filtering like that before. Is this something that all Kamailio users will hit?

Lastly, a few methods (INFO, SUBSCRIBE, NOTIFY) are missing from our Allows header, as well. We'll work on getting that fixed ASAP.

wakamoleguy avatar Apr 29 '14 13:04 wakamoleguy

Hi wakamoleguy,

i will look into Kamailio and give you feedback about its behavior. I use your library to exchange data with a PJSUA client written in python and got different errors from Python side when the initialization on Javascript side is different than it should be. Most of the time Method not allowed as intended, but sometimes

Message delivery failed for message hello to <sip:[email protected]> : No error (2/SL)

Mysterious :smile: , there are so many combinations with client/server/client. Hopefully the Kamailio in debug mode gives me more information about that error. But the library works really good if you initialize the events before the SIP Register.

A big thanks here for you and your team for this nice library, it saves me a lot of trouble on my thesis.

Djcd

Djcd avatar Apr 29 '14 14:04 Djcd

Lastly, a few methods (INFO, SUBSCRIBE, NOTIFY) are missing from our Allows header, as well. We'll work on getting that fixed ASAP.

I added INFO and NOTIFY in https://github.com/onsip/SIP.js/commit/fcfa46286fa3022c76429883d2a7ad903fc7418e. To what extent does SIP.js support being a notifier, @james-onsip?

josephfrazier avatar Jun 21 '14 17:06 josephfrazier

SIP.js doesn't support being a notifier currently, and if we added it, there would be the need to figure out which event packages we wanted to support. We could leave that piece to the user with a callback, but it doesn't seem to be a very urgent request (at the moment). I think it's alright leaving SUBSCRIBE off for the time being, but it's certainly a to-do for the future.

james-criscuolo avatar Jun 21 '14 23:06 james-criscuolo