Ok, I modified as follows.
sip.conf
[general]
register => user:pass@montreal.voip.ms
context = unauthenticated
allowguest = yes
allowoverlap = no
udpbindaddr = 0.0.0.0
tcpenable = no
transport = udp
srvlookup = yes
defaultexpiry = 120
disallow = all
allow = ulaw
allow = alaw
;allow = gsm
language = en
useragent = Asterisk PBX
registerattempts = 50
sdpsession = Asterisk PBX
ignoreregexpire = no
[voipms]
type = friend
user = user
host = montreal.voip.ms
fromuser = user
fromdomain = montreal.voip.ms
secret = pass
insecure = invite
disallow = all
allow = ulaw
allow = alaw
context = incoming
trustrpid = yes
sendrpid = yes
nat = comedia
extensions.conf
[general]
static = yes
writeprotect = yes
clearglobalvars = no
; default context
[unauthenticated]
exten => s,1,Answer()
same => n,AGI(googletts.agi,"Unauthenticated user, hanging up.",en)
same => n,Hangup()
[macro-ParseIncoming]
exten => s,1,GotoIf($[${CALLERID(number)} = 55512345]?callback:isplcid)
same => n(callback),Verbose(CID=${CALLERID(number)})
same => n,Set(CallBackNumber=${CALLERID(number)})
same => n,system(echo -e "Channel: SIP/voipms/${CallBackNumber}\\nMaxRetries: 2\\nRetryTime: 10\\nWaitTime: 20\\nConte
xt: callback\\nExtension: CallbackExt\\nPriority: 1" > /tmp/callback.call)
same => n,System(chmod 755 /tmp/callback.call)
same => n,System(mv /tmp/callback.call /var/spool/asterisk/outgoing)
same => n,Hangup(16)
same => n(isplcid),Verbose("ISPLCID")
same => Hangup()
[incoming]
exten => 5556789,1,Macro(ParseIncoming)
[callback]
exten => CallbackExt,1,Answer()
same => n,AGI(googletts.agi,"Asterisk calling back",en)
Now here is what happens in Asterisk’s console when I call my DID 5556789 from my cellphone 5551234:
-- Executing [5556789@incoming:1] Macro("SIP/voipms-00000000", "ParseIncoming") in new stack
-- Executing [s@macro-ParseIncoming:1] GotoIf("SIP/voipms-00000000", "1?callback:isplcid") in new stack
-- Goto (macro-ParseIncoming,s,2)
-- Executing [s@macro-ParseIncoming:2] Verbose("SIP/voipms-00000000", "CID=5551234") in new stack
CID=5551234
-- Executing [s@macro-ParseIncoming:3] Set("SIP/voipms-00000000", "CallBackNumber=5551234") in new stack
-- Executing [s@macro-ParseIncoming:4] System("SIP/voipms-00000000", "echo -e "Channel: SIP/voipms/5551234\\nMaxRetries: 2\\nRetryTime: 10\\nWaitTime: 20\\nContext: callback\\nExtension: CallbackExt\\nPriority: 1" > /tmp/callback.call") in new stack
-- Executing [s@macro-ParseIncoming:5] System("SIP/voipms-00000000", "chmod 755 /tmp/callback.call") in new stack
-- Executing [s@macro-ParseIncoming:6] System("SIP/voipms-00000000", "mv /tmp/callback.call /var/spool/asterisk/outgoing") in new stack
-- Attempting call on SIP/voipms/5551234 for CallbackExt@callback:1 (Retry 1)
== Using SIP RTP CoS mark 5
-- Executing [s@macro-ParseIncoming:7] Hangup("SIP/voipms-00000000", "16") in new stack
== Spawn extension (macro-ParseIncoming, s, 7) exited non-zero on 'SIP/voipms-00000000' in macro 'ParseIncoming'
== Spawn extension (incoming, 5556789, 1) exited non-zero on 'SIP/voipms-00000000'
[Dec 29 12:53:08] NOTICE[24614][C-00000001]: chan_sip.c:22629 handle_response_invite: Failed to authenticate on INVITE to '"asterisk" <sip:user@montreal.voip.ms>;tag=as157f2ef7'
> Channel SIP/voipms-00000001 was never answered.
[Dec 29 12:53:08] NOTICE[24637]: pbx_spool.c:389 attempt_thread: Call failed to go through, reason (8) Congestion (circuits busy)
-- Attempting call on SIP/voipms/5551234 for CallbackExt@callback:1 (Retry 2)
== Using SIP RTP CoS mark 5
[Dec 29 12:53:18] NOTICE[24614][C-00000002]: chan_sip.c:22629 handle_response_invite: Failed to authenticate on INVITE to '"asterisk" <sip:user@montreal.voip.ms>;tag=as3e745b7f'
> Channel SIP/voipms-00000002 was never answered.
[Dec 29 12:53:18] NOTICE[24638]: pbx_spool.c:389 attempt_thread: Call failed to go through, reason (8) Congestion (circuits busy)
-- Attempting call on SIP/voipms/5551234 for CallbackExt@callback:1 (Retry 3)
== Using SIP RTP CoS mark 5
[Dec 29 12:53:28] NOTICE[24614][C-00000003]: chan_sip.c:22629 handle_response_invite: Failed to authenticate on INVITE to '"asterisk" <sip:user@montreal.voip.ms>;tag=as1660e46f'
> Channel SIP/voipms-00000003 was never answered.
[Dec 29 12:53:28] NOTICE[24639]: pbx_spool.c:389 attempt_thread: Call failed to go through, reason (8) Congestion (circuits busy)
[Dec 29 12:53:28] NOTICE[24639]: pbx_spool.c:392 attempt_thread: Queued call to SIP/voipms/5551234 expired without completion after 2 attempts
I can’t understand why it is failing to authenticate user@montreal.voip.ms.
I tried with type = peer and type = friend, I tried with insecure = invite or insecure = no and while the errors will vary, it will never place the call.
I’m at my wits end. Any pointer appreciated.