Sip 2.0 bad address when making inbound call

Hi I am new to asterisk, I am getting an error when dialing a certain ext in my dialplan. I can successfully dial ext 1001 and 1002, in context home-phones, and I can dial to external PSTN’s from ext 1001 and 1002. but if I dial any extension starting with 400X! I get a bad address. How can I troubleshoot this to determine what asterisk is recieving and processing? I can see by pjsip show history that asterisk is recieving the INVITE message
INVITE sip:40011@98.174.244.232 SIP/2.0
however, I can not determine why it believes this is a bad/incomplete address. Can someone tell me how to troubleshoot this or where I need to be looking?

Extensions.conf
[rooms]
exten => _400X!,1,GotoIf($[${DB_EXISTS(openmeetings/rooms/${EXTEN})}]?ok:notavail)
exten => _400X!,n(ok),SET(PIN=${DB(openmeetings/rooms/${EXTEN})})
exten => _400X!,n,Set(CONFBRIDGE(user,template)=sip_user)
exten => _400X!,n,Set(CONFBRIDGE(user,pin)=${PIN})
exten => _400X!,n(ok),Confbridge(${EXTEN},default_bridge,)
exten => _400X!,n,Hangup
exten => _400X!,n(notavail),Answer()
exten => _400X!,n,Playback(invalid)
exten => _400X!,n,Hangup

[rooms-originate]
exten => _400X!,1,Confbridge(${EXTEN},default_bridge,sip_user)
exten => _400X!,n,Hangup

[rooms-out]
; *****************************************************
; Extensions for outgoing calls from Openmeetings room.
; *****************************************************

[rooms-omsip]
exten => _400X!,1,GotoIf($[${DB_EXISTS(openmeetings/rooms/${EXTEN})}]?ok:notavail)
exten => _400X!,n(ok),Confbridge(${EXTEN},default_bridge,omsip_user)
exten => _400X!,n(notavail),Hangup

[home-phones]

exten => 1001,1,Dial(PJSIP/horace-desktop)

exten => 1002,1,Dial(PJSIP/horace-cellphone)

SIP Capture
eetings*CLI> pjsip show history entry 0,1,2,3,4
<— History Entry 0 Received from 98.174.244.227:55511 at 1654547214 —>
INVITE sip:40011@98.174.244.232 SIP/2.0
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.q08e7DpMh
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232
CSeq: 20 INVITE
Call-ID: 1nAgnAsdNJ
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 524
Contact: sip:horace-cellphone@98.174.244.227:55511;transport=udp;expires=3599;+sip.instance=“urn:uuid:b8fc657a-451d-00f9-b74d-6a441ea04ea8
User-Agent: LinphoneAndroid/4.6.9 (Galaxy Note9) LinphoneSDK/5.1.38 (tags/5.1.38^0)
Content-Type: application/sdp
Content-Length: 524

v=0
o=horace-cellphone 3844 1248 IN IP4 10.10.0.8
s=Talk
c=IN IP4 10.10.0.8
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<— History Entry 1 Sent to 98.174.244.227:55511 at 1654547214 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.q08e7DpMh
Call-ID: 1nAgnAsdNJ
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232;tag=z9hG4bK.q08e7DpMh
CSeq: 20 INVITE
WWW-Authenticate: Digest realm=“asterisk”,nonce=“1654547214/d9c19ddb57943b0efab614ec95b1dd2e”,opaque=“2205cee34fd92498”,algorithm=md5,qop=“auth”
Server: Asterisk PBX 16.13.0
Content-Length: 0

meetings*CLI> pjsip show history entry 2
<— History Entry 2 Received from 98.174.244.227:55511 at 1654547214 —>
ACK sip:40011@98.174.244.232 SIP/2.0
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.q08e7DpMh
Call-ID: 1nAgnAsdNJ
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232;tag=z9hG4bK.q08e7DpMh
Contact: sip:horace-cellphone@98.174.244.227:55511;transport=udp;expires=3599;+sip.instance=“urn:uuid:b8fc657a-451d-00f9-b74d-6a441ea04ea8
Max-Forwards: 70
CSeq: 20 ACK
Content-Length: 0

meetings*CLI> pjsip show history entry 3
<— History Entry 3 Received from 98.174.244.227:55511 at 1654547214 —>
INVITE sip:40011@98.174.244.232 SIP/2.0
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.cuFxdCQj9
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232
CSeq: 21 INVITE
Call-ID: 1nAgnAsdNJ
Max-Forwards: 70
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 524
Contact: sip:horace-cellphone@98.174.244.227:55511;transport=udp;expires=3599;+sip.instance=“urn:uuid:b8fc657a-451d-00f9-b74d-6a441ea04ea8
User-Agent: LinphoneAndroid/4.6.9 (Galaxy Note9) LinphoneSDK/5.1.38 (tags/5.1.38^0)
Authorization: Digest username=“horace-cellphone”, realm=“asterisk”, nonce=“1654547214/d9c19ddb57943b0efab614ec95b1dd2e”, uri="sip:40011@98.174.244.232", response=“9a0b0b3c03a8e051d9a679e6ed881219”, algorithm=md5, cnonce=“sugQ0tgZewCu5R5D”, opaque=“2205cee34fd92498”, qop=auth, nc=00000001
Content-Type: application/sdp
Content-Length: 524

v=0
o=horace-cellphone 3844 1248 IN IP4 10.10.0.8
s=Talk
c=IN IP4 10.10.0.8
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
m=audio 7078 RTP/AVP 96 97 98 0 8 18 99 100 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:99 telephone-event/48000
a=rtpmap:100 telephone-event/16000
a=rtpmap:101 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

meetings*CLI> pjsip show history entry 4
<— History Entry 4 Sent to 98.174.244.227:55511 at 1654547214 —>
SIP/2.0 484 Address Incomplete
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.cuFxdCQj9
Call-ID: 1nAgnAsdNJ
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232;tag=7f1d8a01-f100-4876-8b95-091474e4bf37
CSeq: 21 INVITE
Server: Asterisk PBX 16.13.0
Content-Length: 0

meetings*CLI> pjsip show history entry 5
<— History Entry 5 Received from 98.174.244.227:55511 at 1654547214 —>
ACK sip:40011@98.174.244.232 SIP/2.0
Via: SIP/2.0/UDP 10.10.0.8:55511;rport=55511;received=98.174.244.227;branch=z9hG4bK.cuFxdCQj9
Call-ID: 1nAgnAsdNJ
From: “horace-cellphone” sip:horace-cellphone@98.174.244.232;tag=gImQ9Wa5L
To: sip:40011@98.174.244.232;tag=7f1d8a01-f100-4876-8b95-091474e4bf37
Contact: sip:horace-cellphone@98.174.244.227:55511;transport=udp;expires=3599;+sip.instance=“urn:uuid:b8fc657a-451d-00f9-b74d-6a441ea04ea8
Max-Forwards: 70
CSeq: 21 ACK
Content-Length: 0

meetings*CLI>

dialplan debug output

[ Context ‘home-phones’ created by ‘pbx_config’ ]
9:N:-:1:

  •   0:N:-:1:
    
  •   +       0:N:-:1:
    
  •   +       +       0:N:-:1:EXTEN:9000(0x55b5aa5ca190)
    

1:N:-:1:

  •   0:N:-:1:
    
  •   +       0:N:-:1:
    
  •   +       +       2:N:-:1:EXTEN:1002(0x55b5aa5c9e60)
    
  •   +       +       1:N:-:1:EXTEN:1001(0x55b5aa5c99a0)
    

X:Y:-:2608:

  •   X:Y:-:2608:
    
  •   +       X:Y:-:2608:
    
  •   +       +       X:Y:-:2608:
    
  •   +       +       +       X:Y:-:2608:
    
  •   +       +       +       +       X:Y:-:2608:
    
  •   +       +       +       +       +       X:Y:-:2608:
    
  •   +       +       +       +       +       +       X:Y:-:2608:
    
  •   +       +       +       +       +       +       +       X:Y:-:2608:
    
  •   +       +       +       +       +       +       +       +       X:Y:-:2608:EXTEN:_XXXXXXXXXX(0x55b5aa5ca6e0)
    

[ Context ‘rooms-omsip’ created by ‘pbx_config’ ]
4:Y:-:1:

  •   0:Y:-:1:
    
  •   +       0:Y:-:1:
    
  •   +       +       X:Y:-:2608:
    
  •   +       +       +       !:Y:-:163840:EXTEN:_400X!(0x55b5aa5c90d0)
    

[ Context ‘rooms-out’ created by ‘pbx_config’ ]

 No Pattern Trie present. Perhaps the context is empty...or there is trouble...

[ Context ‘rooms-originate’ created by ‘pbx_config’ ]
4:Y:-:1:

  •   0:Y:-:1:
    
  •   +       0:Y:-:1:
    
  •   +       +       X:Y:-:2608:
    
  •   +       +       +       !:Y:-:163840:EXTEN:_400X!(0x55b5aa5c8870)
    

[ Context ‘rooms’ created by ‘pbx_config’ ]
4:Y:-:1:

  •   0:Y:-:1:
    
  •   +       0:Y:-:1:
    
  •   +       +       X:Y:-:2608:
    
  •   +       +       +       !:Y:-:163840:EXTEN:_400X!(0x55b5aa5c78f0)

witch context are the phones configured to use
it look like they use “home-phones” where you only have 2 numbers configured

yes they do you use home-phones, but shouldn’t I be able to dial between contexts?

[ Please mark up logs and configurations as preformatted text, as I’m having trouble deciding whether the requests are malformed, or the forum garbled them. ]

No. That suggests you don’t understand contexts. Contexts determine the numbers you can dial. You can include one context in another, so you can, for example, have have a from-trunk context that can only call local phones, and a from-internal, which includes from-trunk, but adds outgoing calls.

However, I’m having trouble understanding why you are getting 484, rather than 404, as 40011 is not an initial match on anything in your rooms context.

I half remember there is some unusual or invalid input that produces this symptom.

I don’t believe expires is valid in the Contact header of an INVITE, rather than REGISTER, although it might just be ignored as unknown.

Thanks David551, As soon as I learn how to do the mark up here, I will resubmit the logs and configuration information. I included the rooms and rooms-omsip context in home-phones and the call now goes through, but I am unable to hear any of the systems prompts such as getpin.gsm

Preformatted text == Setting global variable ‘SIPDOMAIN’ to ‘98.174.244.232’
– Executing [40011@home-phones:1] GotoIf(“PJSIP/horace-cellphone-00000003”, “1?ok:notavail”) in new stack
– Goto (home-phones,40011,2)
– Executing [40011@home-phones:2] Set(“PJSIP/horace-cellphone-00000003”, “PIN=7777”) in new stack
– Executing [40011@home-phones:3] Set(“PJSIP/horace-cellphone-00000003”, “CONFBRIDGE(user,template)=sip_user”) in new stack
– Executing [40011@home-phones:4] Set(“PJSIP/horace-cellphone-00000003”, “CONFBRIDGE(user,pin)=???”) in new stack
– Executing [40011@home-phones:5] ConfBridge(“PJSIP/horace-cellphone-00000003”, “40011,default_bridge,”) in new stack
> 0x7f8204005db0 – Strict RTP learning after remote address set to: 10.10.0.8:7078
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-getpin.gsm’ (language ‘en’)
> 0x7f8204005db0 – Strict RTP qualifying stream type: audio
> 0x7f8204005db0 – Strict RTP switching source address to 98.174.244.227:7078
> 0x7f8204005db0 – Strict RTP learning complete - Locking on source address 98.174.244.227:7078
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-invalidpin.gsm’ (language ‘en’)
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-getpin.gsm’ (language ‘en’)
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-invalidpin.gsm’ (language ‘en’)
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-getpin.gsm’ (language ‘en’)
– <PJSIP/horace-cellphone-00000003> Playing ‘conf-invalidpin.gsm’ (language ‘en’)
== Spawn extension (home-phones, 40011, 5) exited non-zero on ‘PJSIP/horace-cellphone-00000003’

No. Timestamp (Dir) Address SIP Message
===== ========== ============================== ===================================
00000 1654561786 * <== 98.174.244.227:55511 INVITE sip:40011@98.174.244.232 SIP/2.0
00001 1654561786 * ==> 98.174.244.227:55511 SIP/2.0 401 Unauthorized
00002 1654561786 * <== 98.174.244.227:55511 ACK sip:40011@98.174.244.232 SIP/2.0
00003 1654561786 * <== 98.174.244.227:55511 INVITE sip:40011@98.174.244.232 SIP/2.0
00004 1654561786 * ==> 98.174.244.227:55511 SIP/2.0 100 Trying
00005 1654561786 * ==> 98.174.244.227:55511 SIP/2.0 200 OK
00006 1654561786 * <== 98.174.244.227:55511 ACK sip:98.174.244.232:5060 SIP/2.0
00007 1654561832 * ==> 98.174.244.227:55511 BYE sip:horace-cellphone@98.174.244.227:55511;transport=udp SIP/2.0
00008 1654561832 * <== 98.174.244.227:55511 SIP/2.0 200 Ok

hi david551,
The call are going through but I am unable to hear the audio files being played, I have look else where in this forum and found that I should turn nat on in Sip.conf, I turned it on both Sip.conf and PJSip.conf files. I am receiving the ACK, but the audio files like conf-getpin.gsm I can not hear being played, I can enter the pin and the get more audio files that are playing but I can not hear them.

We need to know where the NAT is in your system, and it helps to know how well the other side supports NAT and it it also properly configured for it. Lack of audio can also be caused by bad firewall configurations.

For NAT at your side, you need to configure your public address and which networks are part of your LAN. Doing the equivalent for the other side will avoid the need to use nat=, but that provides work arounds if the other side insists on sending its private addresses.

Looking at your call traces, the far side is behind NAT and only partially compensating, so you do need nat=comedia. nat=force_rport is probably redundant, as the other side seems to be actually using rport, but shouldn’t do any harm.

My server is exposed directly to the internet. The rest of my network is behind a NATted firewall. I am using a Coturn server which is on the same box as my asterisk server. I am using Openmeetings for video and audio and all works there with the exception of these inbound and outbound calls to and from Openmeetings. So server is not natted but all clients are. I hope that answers your question. On Firewall:
WAN SIP ALG disable. NAT filtering was set to Secure. I changed it to “Open”
On the Asterisk box, I have added port 10000:20000 /udp on the public address.
Even after disabling UFW I am unable to hear audio/IVR messages.

Can you get a pcap trace on the WAN side and check whether there is any media at the doorstep?

When you say you added the port range 10000 to 20000, does that mean that this is for incoming traffic? This port range is used by Asterisk, but that is usually not honoured by the other side. You could also check the SDP parameters of the other side’s requests/responses (there is already the port 7078 out of the Asterisk range).

Ok I am able to dial into the conference, I have to enter the PIN for the conference and I am connected. I can hear audio when I speak in the conference room, but I there is no audio from conference room to phone. So one way audio → into conference room but no audio from asterisk or the conference room. No IVR messages receivied. I will see if I can get a pcap (been a minute since I used wireshark).

That might not work as expected. I’d be interested in the WAN side traffic, so your router would need to able to capture.

My router which is a netgear nighthawk does not have the ability to capture packets on the the WAN side.

I see, more of a budgie than a hawk. If you want to analyze this kind of problem, then you might consider a decent router with a fiber/DSL/LTE modem in front of it. It probably also means that you cannot check the state of the various connections, i.e. the timers of the NAT tables. I’d recommend pfSense of OPNsense.

This router has a cable modem in front of it 200MBPS business internet. But it is unable to capture WAN traffic.

This would mean you have this configuration: WAN <-> Cable Modem <-> Netgear Nighthawk <-> LAN. Is that right? Seriously, once you find out how a good router can help you, you don’t want to go back. Of course, you can virtualize the router, in case you have a server with some spare resources.

In this case, the proper pcap trace would tell you whether the other side does actually send media to your place.

Correct. I am looking at pfSense, seeing if I can fit it into the budget. I might have to take an old machine and add another NIC to it use some sort of open source software.

Bare metal is also fine. If the box has enough power and RAM, then consider a Linux qemu/kvm system (CentOS 8 Stream, Oracle Linux, Debian 11, Fedroa 36 all fine, Ubuntu not really). My recommendations would be a Fedora 36 server. It’s easier for testing when you have snapshots…

I don’t know whether the admins will object, but you can ask questions about the router. An old PC is enough and a cheap Realtek NIC suffices. Later, you want something better and more suitable.

that will take a little time to do, But in the mean time I am capturing from the server side. I can confirm that the server is sending the RTP traffic with the audio, and I can play the stream, but it is not making it to the calling device. I also entered the PIN and capture the conversation in the conference room. I was also able to play that stream. It is using the g711 ulaw. So it appears the stream from the phone is making it to the server, but the stream from the server is not making it to the phone.

OK, I figured out the problem. The problem is in the linphone softclient. The client needs to have use a stun server. The only way to do it is with a configuration file that must be downloaded from the server when the client registers. I have change to MizuDroid, which allows you to enable the Stun server in the configuration and now everything works. Thanks everyone for your input… This issue can be closed.