sipjs library in angular 6+

554 views
Skip to first unread message

martastuart

unread,
Jul 25, 2018, 3:49:54 AM7/25/18
to SIP.js
Hi, I'm facing the strange issue. 
I use this library in my angular application and it is working perfectly in some cases.
When I building the app without `--prod` flag, it works fine. But when I build the application with the '--prod' flag, like that 'ng build --prod', it is failed on registration on the asterisk. 
And in asterisk console, I see the registration attempts:

registration attempt with --prod flag
REGISTER sip:my.public.pbx SIP/2.0
Via: SIP/2.0/WSS bl2kragnrs0o.invalid;branch=z9hG4bK9449142
Max-Forwards: 70
To: <sip:a076F00000koRdgQ94@my.public.pbx>
From: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=pdgvjjvt02
Call-ID: l8qj9u7bu8uk61m8p56lgt
CSeq: 1034 REGISTER
Authorization: Digest algorithm=MD5, username="a076F00000koRdgQ94", realm="asterisk", nonce="1532443015/54c65280a80fea7e20b6e00e1ef711b7", uri="sip:my.public.pbx", response="cab225f52ad457e3ee7082caab1467bb", opaque="4e63def630d30ac8", qop=auth, cnonce="4jq7bg25if67", nc=00000001
Contact: <sip:undrmpl8@bl2kragnrs0o.invalid;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:287736ec-756e-4bdb-b62c-5466ac828eac>";expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, 100rel, outbound
User-Agent: PhoneApp-devel; sipjs-0.10.0
Content-Length: 0


SIP
/2.0 401 Unauthorized
Via: SIP/2.0/WSS bl2kragnrs0o.invalid;rport=64745;received=xx.xxx.xx.xx;branch=z9hG4bK9449142
Call-ID: l8qj9u7bu8uk61m8p56lgt
From: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=pdgvjjvt02
To: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=z9hG4bK9449142
CSeq: 1034 REGISTER
WWW
-Authenticate: Digest  realm="asterisk",nonce="1532443016/e5c54c68288776679b6ece99c2ede7fd",opaque="470634a56b96145a",algorithm=md5,qop="auth"
Server: cc2-alpha-0.1
Content-Length:  0

registration attempt with no --prod flag
REGISTER sip:my.public.pbx SIP/2.0
Via: SIP/2.0/WSS ejk7e729ucb4.invalid;branch=z9hG4bK1028057
Max-Forwards: 70
To: <sip:a076F00000koRdgQ94@my.public.pbx>
From: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=9ats00kua6
Call-ID: f7jt3musiu8dgert3vq25o
CSeq: 7575 REGISTER
Authorization: Digest algorithm=MD5, username="a076F00000koRdgQ94", realm="asterisk", nonce="1532443102/00815c6c42330c5bea505a7208a776cd", uri="sip:my.public.pbx", response="d5c5a6973448c45d9c54288ef05e6bd1", opaque="599322a412e15903", qop=auth, cnonce="urto5aht35bv", nc=00000001
Contact: <sip:4rvh90rr@ejk7e729ucb4.invalid;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:c8e2b960-4ea5-4c1c-9dc9-dae83f5179c5>";expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, 100rel, outbound
User-Agent: PhoneApp-devel; sipjs-0.10.0
Content-Length: 0


SIP
/2.0 200 OK
Via: SIP/2.0/WSS ejk7e729ucb4.invalid;rport=65130;received=xx.xxx.xx.xx;branch=z9hG4bK1028057
Call-ID: f7jt3musiu8dgert3vq25o
From: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=9ats00kua6
To: <sip:a076F00000koRdgQ94@my.public.pbx>;tag=z9hG4bK1028057
CSeq: 7575 REGISTER
Date: Tue, 24 Jul 2018 14:38:22 GMT
Contact: <sip:4rvh90rr@xx.xxx.xx.xx:65130;transport=ws>;expires=599
Server: cc2-alpha-0.1
Content-Length:  0

Eric Green

unread,
Jul 25, 2018, 8:59:31 AM7/25/18
to SIP.js
Please provide full logs with traceSip from SIP.js
Message has been deleted

martastuart

unread,
Jul 25, 2018, 9:08:01 AM7/25/18
to SIP.js
I've solved this issue. I have changed the import string in my service from
import * as SIP from 'sip.js';
to
import * as SIP from 'sip.js/dist/sip';

and now it works fine. Probably this issue relates to the webpack plugin which is used in the sip.js library.

James Criscuolo

unread,
Jul 25, 2018, 9:42:27 AM7/25/18
to SIP.js
Upon doing some research, it appears having npm automatically include the minified file is no longer best practice (not sure if it ever was). I've pushed a commit to change this, so that your original line will pull in "sip.js" instead of "sip.min.js". This will not break the change you have made, but you can undo that change when we release (and you update to that release).

Thanks,
James

Vinícius Montanheiro

unread,
Aug 15, 2019, 3:01:55 PM8/15/19
to SIP.js
Hey man, how did you set the register authorization after the Unauthorized response and resend using SIPJS?? 

Thanks.
Reply all
Reply to author
Forward
0 new messages