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

Not sending 200 after receiving notify

Open EndikaRamos opened this issue 4 years ago • 1 comments

Hello,

We have implemented a webphone using version 20 of sip.js. Although I successfully send the subscribe and receive the NOTIFY event associated with that subscribe. It doesn't seem that sip.js is replying to NOTIFY to the PBX:

Subscriber Notifier |-----SUBSCRIBE---->| Request state subscription |<-------200--------| Acknowledge subscription |<------NOTIFY----- | Return current state information |--------200------->| -> This event is not being sent

the notify event that the websocket is receiving is (hiding sensitive data, such as IPs)

SIP/2.0 200 OK Via: SIP/2.0/WSS webphone.domain.com;received=212.142.137.31;branch=z9hG4bK6506673;rport=39230 Record-Route: sip:PBX_IP;r2=on;lr Record-Route: sip:PUBLIC_IP:1080;transport=wss;r2=on;lr From: "webphone2" sip:webphone2@SBC_IP;tag=0uaq5n1an3 To: sip:pause_webphone2@SBC_IP;tag=as7282add5 Call-ID: 5btgea0925bv29pv585u CSeq: 2 SUBSCRIBE Server: Irontec IVOZ Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces,timer,path Expires: 180 Contact: sip:pause_webphone2@PBX_IP:5060;expires=180 Content-Length: 0

Attached is a screenshot of the SIP events of the websocket tab of Google Chrome (developer tools) sipjs

Thanks, Endika

EndikaRamos avatar Oct 20 '21 09:10 EndikaRamos

Yes, I had this issue, too. You'll need to send the 200OK manually. In your Subscriber object, I assume you already delegated with onNotify in order to catch to NOTIFY messages and do something with them (if not - do it). And inside this onNotify delegation, you can just add the following line: notification.accept();

Something like that:

subscriber = new Subscriber(this.userAgent, targetURI, eventType, subscribeOptions);

subscriber.delegate = {
	onNotify: (notification: Notification) =>
	{
		... doing stuff here ...
		...
		notification.accept();
	}
};

subscriber.subscribe();

slavikbialik avatar Oct 24 '21 10:10 slavikbialik

@slavikbialik is correct. If a handler for notifications is provided, the handler must accept (or reject) the notification.

I've updated in code documentation to make it clear the delegate is responsible for sending the response which will go out with the updated documentation in next release.

john-e-riordan avatar Oct 19 '22 14:10 john-e-riordan