SIP.js
SIP.js copied to clipboard
Double Subscribe Request at the same message Request
Hi,
I'm using SIPJS 20 and implementing contact presence as at the following link
https://github.com/onsip/SIP.js/blob/master/docs/api/sip.js.subscriber.md
everything worked perfect except that some times , the asterisk server response with error causing unregister of agent , when i used wireshark to follow the error i found out double subscribe request at the same sip request . as found at the following image
I don't know why and how this occurs all what the code doing is a simple loop for my contacts extensions to subscribe to their presence and it is working although that suddenly my user agent getting registered due to the above error . i tried to set 100 millisecond timeout between every subscribe request for each extension but still got the error randomly . any help Please about the error ?
They are likely just getting auth'ed, but. a full sip trace would confirm.
Hi @james-criscuolo thanks for your reply. no they are already authorized successfully . the large length in request is due to double SUBSCRIBE not auth. unfortunately when this case happens the asterisk server responds with an error and stop the user agent connection and registration that's why I don't have a sip trace and traced it with Wireshark but I can try to send you the details of sip corrupted SUBSCRBE message
If you could post the pcap from the wireshark, that's a full sip trace.
Hi James ,
I sent you a full sip trace from Wireshark to your email , your help is appreciated
Thanks
hi @james-criscuolo ,
I sent you the full sip trace on email , i hope you have time to see it.
I made a small modification at my code . the subscriptions of extension's presence will start at onConnect event of user agent
onConnect(){ if(this.userAgent.state === UserAgentState.Started){ this.subscribeAllPresence(); }
instead of registrar state change to registered (this is the old code 👎 )
this.registerer.stateChange.addListener((registerState) => { switch (registerState) { case RegistererState.Registered: this.subscribeAllPresence(); break; } });
and unsubscribe at the onDiconnect event
onDisconnect(error:Error){ this.unSubscribeAllPresence(); }
also I set the following values for useragent to reconnect upon connection drops
connectionTimeout: 10, maxReconnectionAttempts:240 , reconnectionTimeout: 15
the double SUBSCRIBE requests is much less after these changes but it still happens sometimes .
I confirm I'm still use the subscriber as at the following link : https://github.com/onsip/SIP.js/blob/master/docs/api/sip.js.subscriber.md
the only difference that onNotify function I'm adding notification.accept();
then processing the request data to get the presence notification which is working successfully if the double SUBSRIBE request didn't happened .
any help about the double SUBSCRIBE request ?any recommendations about best practices to start the subscription or end it ?
Thanks in advance, Marwa
Hello, @MarwaAbuEssa: Have you fixed this issue? I'm facing the same problem using sipjs latest 0.20.0. The subscription goes correctly, but after few times another subscription is issued automatically but with empty content. Thanks
Hi @slachtar ,
sorry for the late reply, you need to ensure that you have only one instance of user agent during your app running and ensure on websocket disconnect and reconnect again to re-send your subscriptions again if it is terminated.
I hope this help , Thanks