[Help] DID is not being received by my PBX and other problems


(United Kingdom) #1

Hello,

I’ve recently reinstalled FreePBX into a virtual machine after decommissioning my physical PC. It is only for family and home business use so not business critical as I have all calls forwarded to my mobile through my trunk provider.

I am only able to receive calls on my main number, any other numbers fail to register at the INVITE stage and I am not receiving any DID from the trunk so all calls are played the ‘not in service’ message as I have no default inbound route. I have been in touch with my provider and they have given me snippets of logs and it looks like the problem is at my end - I was wondering if anyone had any ideas to get this working, I have copied settings from my previous physical install so I’m not sure what exactly is happening.

These are the logs, the provider is Andrews and Arnold in the UK.

My Log when I attempt to dial in with a secondary number:

193[2021-02-19 11:02:38] NOTICE[30173] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"07969 XXXXXX" <sip:[07969127392@voiceless.aa.net.uk](mailto:07969XXXXXX@voiceless.aa.net.uk)>' failed for '81.187.30.XXX:5060' (callid: 2021021911023700014@2900-0602-0292-18) - Failed to authenticate
194[2021-02-19 11:02:38] NOTICE[30173] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"07969 127392" <sip:[07969XXXXXX@voiceless.aa.net.uk](mailto:07969XXXXXX@voiceless.aa.net.uk)>' failed for '81.187.30.XXX:5060' (callid: 2021021911023700014@2900-0602-0292-18) - Failed to authenticate
195[2021-02-19 11:02:38] NOTICE[30173] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"07969 XXXXXX" <sip:[07969XXXXXX@voiceless.aa.net.uk](mailto:07969XXXXXX@voiceless.aa.net.uk)>' failed for '81.187.30.XXX:5060' (callid: 2021021911023700014@2900-0602-0292-18) - Failed to authenticate

My provider says:

Our SIP logs show the initial invite followed
by us sending a 401 asking you to authenticate, which you ack but then
send another invite, which looks to be ignoring our request for you to
authenticate

When I attempt to dial in with my main number:

196[2021-02-19 11:04:25] VERBOSE[3377] pbx_variables.c: Setting global variable 'SIPDOMAIN' to '212.XX.XX.XXX'
197[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk-pjsip-aa:1] Set("PJSIP/aa-00000002", "GROUP()=OUT_2") in new stack
198[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk-pjsip-aa:2] Goto("PJSIP/aa-00000002", "from-trunk,s,1") in new stack
199[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx_builtins.c: Goto (from-trunk,s,1)
200[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk:1] NoOp("PJSIP/aa-00000002", "No DID or CID Match") in new stack
201[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk:2] Answer("PJSIP/aa-00000002", "") in new stack
202[2021-02-19 11:04:25] NOTICE[30173] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"07969 XXXXXX" <sip:[07969XXXXXX@voiceless.aa.net.uk](mailto:07969XXXXXX@voiceless.aa.net.uk)>' failed for '81.187.30.114:5060' (callid: 2021021911042500011@2900-0602-0292-18) - Failed to authenticate
203[2021-02-19 11:04:25] WARNING[22100][C-00000003] chan_sip.c: This function can only be used on SIP channels.
204[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk:3] Log("PJSIP/aa-00000002", "WARNING,Friendly Scanner from ") in new stack
205[2021-02-19 11:04:25] WARNING[22100][C-00000003] Ext. s: Friendly Scanner from
206[2021-02-19 11:04:25] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk:4] Wait("PJSIP/aa-00000002", "2") in new stack
207[2021-02-19 11:04:27] VERBOSE[22100][C-00000003] pbx.c: Executing [s@from-trunk:5] Playback("PJSIP/aa-00000002", "ss-noservice") in new stack
208[2021-02-19 11:04:27] VERBOSE[22100][C-00000003] file.c: <PJSIP/aa-00000002> Playing 'ss-noservice.ulaw' (language 'en_GB')

This is my providers INVITE to my PBX for dialing into my main account number:

[81.187.30.XXX:5060](https://81.187.30.118:5060) - [212.XX.XX.XXX:5060](https://212.56.94.122:5060)
2021-02-18T21:46:02.302094Z
INVITE sip:[s@212.XX.XX.XXX](mailto:s@212.XX.XX.XXX):5060;line=cpazlet SIP/2.0
Via: SIP/2.0/UDP [81.187.30.XXX](https://81.187.30.XXX);branch=z9hG4bK2021021821460200001-1;rport
CSeq: 1 INVITE
Max-Forwards: 68
User-Agent: FireBrick/1.55.008
Call-ID: 2021021821460200001@2900-0602-0292-18
From: "07969 XXXXXX"
<[sip:07969XXXXXX@voiceless.aa.net.uk](mailto:sip:07969127392@voiceless.aa.net.uk)>;tag=2021021821460200001
To: <sip:[s@212.XX.XX.XXX](mailto:s@212.XX.XX.XXX):5060;line=cpazlet>
Contact: <[sip:2021021821460200001@81.187.30.X](mailto:sip:2021021821460200001@81.187.30.118)XX>
Content-Type: application/sdp
Content-Length: 188
v=0
o=- 21780 0 IN IP4 [81.187.30.X](https://81.187.30.118)XX
s=call
c=IN IP4 [81.187.30.](https://81.187.30.118)XXX
t=0 0
m=audio 21780 RTP/AVP 8 101
a=rtpmap:8 pcma/8000
a=rtpmap:101 telephone-event/8000
a=ptime:20
a=sendrecv

I am thinking about trying to set the trunk up with chan_sip but as it will, at some point, be depreceated I feel like it would be best to get this working properly with PJSIP now rather than later.

I am running my PBX through one-to-one NAT with all ports directly mapped between the public IP and the private IP.

If anyone has any suggestions of what to try or even where to look to get it working I’d be appreciative. It might be a simple oversight on my part as I am not particularly experienced in SIP, I do have experience with networking as a whole though.

FreePBX 15.0.17.24
Asterisk 16.13.0


#2

how is your inbound route set up in FreePBX? do you have the Main number did listed or is it set to “any?”


(Lorne Gaetz) #3

There is some confusion here. Your provider states they respond to an INVITE with 401, but that is almost certainly an OUTBOUND call they are talking about, there should be no 401 auth process on an inbound call, and in fact the log lines show the inbound INVITE arriving successfully:

Executing [s@from-trunk-pjsip-aa:1] 

The s shows that the provider does not send the DID as part of the INVITE, so you need to look at the rest of the INVITE headers and see if the DID is in there anywhere, or if there’s some other string that uniquely identifies the call to a specific DID. I’m not seeing it in the To header, what about the Contact header, does that string change with the DID being dialed?

You can easily browse the SIP traffic on your system with sngrep.


#4

I assume that you have a separate trunk for each of your DIDs. If not, I don’t see how this could have worked, because AA aren’t sending the called number in the URI or any header, so please explain.

For each of your trunks:
Set Contact User to the phone number. This should exactly match the value of Username and the value of the DID field of the corresponding Inbound Route.
Set Match (Permit) to 81.187.30.0/24 , which will allow for their sending calls from multiple IP addresses

Also, for ease in debugging and as a fallback, set a ‘catchall’ Inbound Route with DID and CID both left blank (Any), that routes to an IVR, Ring Group or other suitable handling when the called number is not known.


(United Kingdom) #5

Thanks for the replies,

That’s part of the confusion, on my previous install - I did have a single trunk which directed calls properly based on the DID.

I have had a further play today, after having set a default route which routes to my ‘Blacklist IVR’ and creating additional trunks. I’ve also checked details using sngrep and get the following:

INVITE 07969XXXXXX@voiceless.aa.net.uk s@212.X.X.X
INVITE 07969XXXXXX@voiceless.aa.net.uk 0333XXXXXXX@pbx.XXXX.uk

So it does look like I am receiving the DID as an 11 digit number in the second INVITE but FreePBX isn’t directing the call properly. Is this because it starts routing at the first INVITE which doesn’t contain the DID?, Should there be two INVITEs or just the one? - All calls go to the default route, even when an inbound route for the 11 digit 0333 number exists.

Note that sometimes, I receive the INVITEs the other way around, the INVITE with the DID first and the INVITE without second.

Thanks for your help so far.


(United Kingdom) #6

Thanks,

It works when using the Contact User option, it is a shame as on my last install it worked with just the one Trunk which made managing it much more simple but it isn’t much more configuration.


#7

I don’t understand.

Does a single trunk (registering the ‘account’ but not a specific DID), receive calls for multiple DIDs? If so and the provider does not put the called number anywhere in the INVITE then that’s a problem on their end.

With multiple registrations and Contact User set, do they still send multiple INVITEs for each call? If so and they correspond to different trunks, you could route for the wrong DID, depending on the order in which the INVITEs arrive.