Contact reachable/unreachable

I’m experimenting a bit with a custom JavaScript SIP client and having a bit trouble to understand what makes an extension reachable/unreachable. From what I understand from the SIP specs, the Contact is involved with this. Normally I would expect something like this in the Asterisk console:

asterisk    |   == WebSocket connection from '127.0.0.1:37868' for protocol 'sip' accepted using version '13'
asterisk    |     -- Added contact 'sip:aq829sul@127.0.0.1:37868;transport=WS' to AOR '2000' with expiration of 600 seconds
asterisk    |   == Endpoint 2000 is now Reachable
asterisk    |     -- Contact 2000/sip:aq829sul@127.0.0.1:37868;transport=WS is now Reachable.  RTT: 60.009 msec

What I get:

asterisk    |   == WebSocket connection from '127.0.0.1:46166' for protocol 'sip' accepted using version '13'
asterisk    |     -- Added contact 'sip:66964985@127.0.0.1:46166;transport=WS' to AOR '2000' with expiration of 600 second
asterisk    |     -- Contact 2000/sip:66964985@127.0.0.1:46166;transport=WS is now Unreachable.  RTT: 0.000 msec
asterisk    |   == WebSocket connection from '127.0.0.1:45768' closed

I compared SIP messages with another client that works as expected, but can’t find any significant differences. Good:

REGISTER sip:sip.dev.ca11.app SIP/2.0
Via: SIP/2.0/WSS p79so5ckn0qa.invalid;branch=z9hG4bK7263061
To: <sip:2000@sip.dev.ca11.app>
From: <sip:2000@sip.dev.ca11.app>;tag=j5a556qi60
CSeq: 5074 REGISTER
Call-ID: fi0l7cac5r556jsk0ubm6n
Max-Forwards: 70
Contact: <sip:aq829sul@p79so5ckn0qa.invalid;transport=ws>;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound, path, gruu
User-Agent: CA11/undefined (Linux/Chrome) ca11
Content-Length: 0


SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS p79so5ckn0qa.invalid;rport=37868;received=127.0.0.1;branch=z9hG4bK7263061
Call-ID: fi0l7cac5r556jsk0ubm6n
From: <sip:2000@sip.dev.ca11.app>;tag=j5a556qi60
To: <sip:2000@sip.dev.ca11.app>;tag=z9hG4bK7263061
CSeq: 5074 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1589308310/f446459e4870165cdeb60a00bae4e0a7",opaque="1f3fcb300f93d738",algorithm=md5,qop="auth"
Server: CA11 Asterisk
Content-Length:  0


REGISTER sip:sip.dev.ca11.app SIP/2.0
Via: SIP/2.0/WSS p79so5ckn0qa.invalid;branch=z9hG4bK6169522
To: <sip:2000@sip.dev.ca11.app>
From: <sip:2000@sip.dev.ca11.app>;tag=j5a556qi60
CSeq: 5075 REGISTER
Call-ID: fi0l7cac5r556jsk0ubm6n
Max-Forwards: 70
Authorization: Digest algorithm=MD5, username="2000", realm="asterisk", nonce="1589308310/f446459e4870165cdeb60a00bae4e0a7", uri="sip:sip.dev.ca11.app", response="1f43875e524e3054f6b2b95af337bdb0", opaque="1f3fcb300f93d738", qop=auth, cnonce="r1ink78qtahb", nc=00000001
Contact: <sip:aq829sul@p79so5ckn0qa.invalid;transport=ws>;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound, path, gruu
User-Agent: CA11/undefined (Linux/Chrome) ca11
Content-Length: 0


SIP/2.0 200 OK
Via: SIP/2.0/WSS p79so5ckn0qa.invalid;rport=37868;received=127.0.0.1;branch=z9hG4bK6169522
Call-ID: fi0l7cac5r556jsk0ubm6n
From: <sip:2000@sip.dev.ca11.app>;tag=j5a556qi60
To: <sip:2000@sip.dev.ca11.app>;tag=z9hG4bK6169522
CSeq: 5075 REGISTER
Date: Tue, 12 May 2020 18:31:50 GMT
Contact: <sip:aq829sul@127.0.0.1:37868;transport=WS>;expires=599
Server: CA11 Asterisk
Content-Length:  0

Wrong:

REGISTER sip:sip.dev.ca11.app SIP/2.0
Via: SIP/2.0/WSS nb4btmdpfcgh.invalid;branch=z9hG4bK7448474
To: <sip:2000@sip.dev.ca11.app>
From: <sip:2000@sip.dev.ca11.app>;tag=qcjf8jrqf3
Call-ID: 93108341049984
CSeq: 1 REGISTER
Max-Forwards: 70
Contact: <sip:66964985@nb4btmdpfcgh.invalid;transport=ws>;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound, path, gruu
User-Agent: CA11/1.0.0 (Linux/Chrome) ca11
Content-Length: 0


SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS nb4btmdpfcgh.invalid;rport=46166;received=127.0.0.1;branch=z9hG4bK7448474
Call-ID: 93108341049984
From: <sip:2000@sip.dev.ca11.app>;tag=qcjf8jrqf3
To: <sip:2000@sip.dev.ca11.app>;tag=z9hG4bK7448474
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1589309316/4be818371b33f013cff5de35c282f0c9",opaque="63af52c62f3d090e",algorithm=md5,qop="auth"
Server: CA11 Asterisk
Content-Length:  0


REGISTER sip:sip.dev.ca11.app SIP/2.0
Via: SIP/2.0/WSS nb4btmdpfcgh.invalid;branch=z9hG4bK8626994
To: <sip:2000@sip.dev.ca11.app>
From: <sip:2000@sip.dev.ca11.app>;tag=qcjf8jrqf3
Call-ID: 93108341049984
CSeq: 2 REGISTER
Max-Forwards: 70
Contact: <sip:66964985@nb4btmdpfcgh.invalid;transport=ws>;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound, path, gruu
User-Agent: CA11/1.0.0 (Linux/Chrome) ca11
Authorization: Digest algorithm=MD5, username="2000", realm="asterisk", nonce="1589309316/4be818371b33f013cff5de35c282f0c9", uri="sip:sip.dev.ca11.app", response="1f029e75ecff01c7a6d4034901661aea", opaque="63af52c62f3d090e", qop=auth, cnonce="4632810274836", nc=00000001
Content-Length: 0


SIP/2.0 200 OK
Via: SIP/2.0/WSS nb4btmdpfcgh.invalid;rport=46166;received=127.0.0.1;branch=z9hG4bK8626994
Call-ID: 93108341049984
From: <sip:2000@sip.dev.ca11.app>;tag=qcjf8jrqf3
To: <sip:2000@sip.dev.ca11.app>;tag=z9hG4bK8626994
CSeq: 2 REGISTER
Date: Tue, 12 May 2020 18:48:36 GMT
Contact: <sip:66964985@127.0.0.1:46166;transport=WS>;expires=599
Server: CA11 Asterisk
Content-Length:  0

Any idea which part of the REGISTER process is involved in this?

Nothing directly. The REGISTER adds the Contact to the AOR. The OPTIONS code when configured on an AOR using qualify then sends a periodic OPTIONS request to the endpoint to determine if it is there. If this fails or in the case of TCP/TLS/WS the connection drops, then the endpoint becomes unreachable.

You should determine why the Websocket is dropping.

I took a closer look to the way I handled OPTIONS and saw I wasn’t properly using the branch from the Options request in the Via header of the response. The Contact is now reachable:

asterisk    |   == Endpoint 2000 is now Reachable
asterisk    |     -- Contact 2000/sip:11496294@127.0.0.1:57580;transport=WS is now Reachable.  RTT: 50.037 msec

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.