Error: didn't received '200 OK' on register

Why does sipsak fail with:

error: didn't received '200 OK' on register ?

I have thufir registered on a Cisco IP phone. From the same computer where Asterisk is running:

thufir@mordor:~$ 
thufir@mordor:~$ sudo sipsak -vvv --usrloc-mode --from sip:demo_alice@localhost --password 123 --sip-uri sip:6003@localhost
No SRV record: _sip._tcp.localhost
No SRV record: _sip._udp.localhost
using A record: localhost
warning: ignoring -i option when in usrloc mode
fqdnhostname: 127.0.1.1
our Via-Line: Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.0238e203;rport;alias

New message with Via-Line:
REGISTER sip:localhost SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.0238e203;rport;alias
From: sip:6003@localhost;tag=1c556565
To: sip:6003@localhost
Call-ID: 475358565@127.0.1.1
CSeq: 1 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:6003@127.0.1.1:57946


registering user 6003... 
request:
REGISTER sip:localhost SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.0238e203;rport;alias
From: sip:6003@localhost;tag=1c556565
To: sip:6003@localhost
Call-ID: 475358565@127.0.1.1
CSeq: 1 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:6003@127.0.1.1:57946


send to: UDP:127.0.0.1:5060
authorizing

received:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.0238e203;alias;received=127.0.0.1;rport=57946
From: sip:6003@localhost;tag=1c556565
To: sip:6003@localhost;tag=as390fd2fe
Call-ID: 475358565@127.0.1.1
CSeq: 1 REGISTER
Server: Asterisk PBX 13.1.0~dfsg-1.1ubuntu3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="38ab0be7"
Content-Length: 0


registering user 6003... 
request:
REGISTER sip:localhost SIP/2.0
Authorization: Digest username="6003", uri="sip:localhost", algorithm=MD5, realm="asterisk", nonce="38ab0be7", response="fa5cac509e948b3d2965586917e2a5fd"
Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.4ad883b2;rport;alias
From: sip:6003@localhost;tag=1c556565
To: sip:6003@localhost
Call-ID: 475358565@127.0.1.1
CSeq: 2 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:6003@127.0.1.1:57946


send to: UDP:127.0.0.1:5060
received:
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 127.0.1.1:57946;branch=z9hG4bK.4ad883b2;alias;received=127.0.0.1;rport=57946
From: sip:6003@localhost;tag=1c556565
To: sip:6003@localhost;tag=as390fd2fe
Call-ID: 475358565@127.0.1.1
CSeq: 2 REGISTER
Server: Asterisk PBX 13.1.0~dfsg-1.1ubuntu3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Content-Length: 0


error: didn't received '200 OK' on register (see above). aborting
thufir@mordor:~$

the 200 OK is return after The SIP server validates the user’scredentials. It registers the user in its contact database and returns a response (200 OK)

server is replyinn back with a 403 Forbidden error

what is being allowed here? The user credentials are accepted with the 200 OK?

However, the REGISTER for 6003 fails? there’s no 6003 per se, it’s thufir at extension 6003:

mordor*CLI> 
mordor*CLI> dialplan show internal
[ Context 'internal' created by 'pbx_config' ]
  '6001' =>         1. Dial(SIP/demo_alice,20)                    [pbx_config]
  '6002' =>         1. Dial(SIP/demo_bob,20)                      [pbx_config]
  '6003' =>         1. Dial(SIP/thufir,20)                        [pbx_config]

-= 3 extensions (3 priorities) in 1 context. =-
mordor*CLI> 
mordor*CLI> sip show peers
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                      
demo_alice/demo_alice     192.168.1.6                              D  Yes        Yes            5060     Unmonitored                                  
demo_bob/demo_bob         (Unspecified)                            D  Yes        Yes            0        Unmonitored                                  
thufir/thufir             192.168.1.5                              D  Yes        Yes            5062     Unmonitored                                  
3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 1 offline]
mordor*CLI>

I have not used sipsak so I can’t speak on the proper configuration to pass to it to make it work, but you are indeed registering as 6003 instead of thufir so the problem is there, not in Asterisk.

Thanks. I thought that I’d tried with thufir but apparently not. Limited success, I think:

thufir @mordor:~$
thufir@mordor:~$ sudo sipsak -vvv --usrloc-mode --from sip:demo_alice@localhost --password 123 --sip-uri sip:thufir@localhost
No SRV record: _sip._tcp.localhost
No SRV record: _sip._udp.localhost
using A record: localhost
warning: ignoring -i option when in usrloc mode
fqdnhostname: 127.0.1.1
our Via-Line: Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.1c1bca40;rport;alias

New message with Via-Line:
REGISTER sip:localhost SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.1c1bca40;rport;alias
From: sip:thufir@localhost;tag=13534fc0
To: sip:thufir@localhost
Call-ID: 324227008@127.0.1.1
CSeq: 1 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:thufir@127.0.1.1:53492


registering user thufir... 
request:
REGISTER sip:localhost SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.1c1bca40;rport;alias
From: sip:thufir@localhost;tag=13534fc0
To: sip:thufir@localhost
Call-ID: 324227008@127.0.1.1
CSeq: 1 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:thufir@127.0.1.1:53492


send to: UDP:127.0.0.1:5060
authorizing

received:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.1c1bca40;alias;received=127.0.0.1;rport=53492
From: sip:thufir@localhost;tag=13534fc0
To: sip:thufir@localhost;tag=as11a64156
Call-ID: 324227008@127.0.1.1
CSeq: 1 REGISTER
Server: Asterisk PBX 13.1.0~dfsg-1.1ubuntu3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="39db0bfd"
Content-Length: 0


registering user thufir... 
request:
REGISTER sip:localhost SIP/2.0
Authorization: Digest username="thufir", uri="sip:localhost", algorithm=MD5, realm="asterisk", nonce="39db0bfd", response="e54fe210187a1255f5af4fd0a1a361c0"
Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.0b9d9eb6;rport;alias
From: sip:thufir@localhost;tag=13534fc0
To: sip:thufir@localhost
Call-ID: 324227008@127.0.1.1
CSeq: 2 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.6
Expires: 15
Contact: sip:thufir@127.0.1.1:53492


send to: UDP:127.0.0.1:5060
    OK

SIP/2.0 200 OK
Via: SIP/2.0/UDP 127.0.1.1:53492;branch=z9hG4bK.0b9d9eb6;alias;received=127.0.0.1;rport=53492
From: sip:thufir@localhost;tag=13534fc0
To: sip:thufir@localhost;tag=as11a64156
Call-ID: 324227008@127.0.1.1
CSeq: 2 REGISTER
Server: Asterisk PBX 13.1.0~dfsg-1.1ubuntu3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Expires: 60
Contact: <sip:thufir@127.0.1.1:53492>;expires=60
Date: Thu, 30 Jun 2016 10:08:40 GMT
Content-Length: 0



All usrloc tests completed successful.
received last message 11.159 ms after first request (test duration).
thufir@mordor:~$ 

Surely it’s possible to at least get the phone to ring if not play a default sound, a sort of “hello world”?

It is, many people do it using a softphone. Like I said I can’t speak for sipsak.