SIP trunk (SPA-3102) fails with No Matching Endpoint when Caller ID enabled

I’m trying to get FreePBX 13.0.192.9 (from the FreePBX Distro) to talk to a Linksys SPA-3102 gateway. The phone->SIP side seems to be working OK, but I’m having a lot of trouble with the PSTN->SIP side.

If I have “PSTN CID For VoIP CID:” disabled on the SPA, the trunk works fine, they’re routed to my “ring all the phones” rule, and generally things work fine.

Now, I’m in the UK, and I’m subscribed to my phone provider’s caller ID service. I’d like to get this data passed through to FreePBX. If I enable “PSTN CID For VoIP CID:”, none of the extension phones ring, and I have these errors in the log:

[2017-07-01 22:32:28] NOTICE[18376] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"PSTN" <sip:[email protected]>' failed for '10.0.0.25:5062' (callid: [email protected]) - No matching endpoint found
[2017-07-01 22:32:28] NOTICE[9141] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"PSTN" <sip:[email protected]>' failed for '10.0.0.25:5062' (callid: [email protected]) - No matching endpoint found
[2017-07-01 22:32:28] NOTICE[9141] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"PSTN" <sip:[email protected]>' failed for '10.0.0.25:5062' (callid: [email protected]) - Failed to authenticate
[2017-07-01 22:32:28] NOTICE[5237] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"PSTN" <sip:[email protected]>' failed for '10.0.0.25:5062' (callid: [email protected]) - No matching endpoint found
[2017-07-01 22:32:28] NOTICE[5237] res_pjsip/pjsip_distributor.c: Request 'INVITE' from '"PSTN" <sip:[email protected]>' failed for '10.0.0.25:5062' (callid: [email protected]) - Failed to authenticate

Note that for my own privacy, I’ve changed the phone numbers:

  • 07912345678 is a placeholder I’m using in place of my mobile phone number (cellphone).
  • 0112345678 is a placeholder for my PSTN number – the phone line attached to the trunk.

Looking at the packets being exchanged with tcpdump, this is what the SPA sends with Caller ID on:

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 10.0.0.25:5062;branch=z9hG4bK-f2d3cef5
From: PSTN <sip:[email protected]>;tag=99ef3fa4bebd7589o1
To: <sip:[email protected]>
Remote-Party-ID: PSTN <sip:[email protected]>;screen=yes;party=calling
Call-ID: [email protected]
CSeq: 103 INVITE
Max-Forwards: 70
Authorization: Digest username="pstntrunk",realm="asterisk",nonce="REDACTED",uri="sip:[email protected]",algorithm=MD5,response="REDACTED",opaque="7887d6803b25f65c",qop=auth,nc=00000001,cnonce="11a2b512"
Contact: PSTN <sip:[email protected]:5062>
Expires: 240
User-Agent: Linksys/SPA3102-5.2.13(GW002)
Content-Length: 436
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER
Supported: x-sipura, replaces
Content-Type: application/sdp

FreePBX responds to this with a “401 Unauthorised” error.

If I turn caller ID off, the INVITE header looks like this:

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 10.0.0.25:5062;branch=z9hG4bK-20525951
From: PSTN <sip:[email protected]>;tag=5ddcc412af5abd1o1
To: <sip:[email protected]>
Remote-Party-ID: PSTN <sip:[email protected]>;screen=yes;party=calling
Call-ID: [email protected]
CSeq: 101 INVITE
Max-Forwards: 70
Contact: PSTN <sip:[email protected]:5062>
Expires: 240
User-Agent: Linksys/SPA3102-5.2.13(GW002)
Content-Length: 436
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER
Supported: x-sipura, replaces
Content-Type: application/sdp

FreePBX responds to this with a “SIP/2.0 100 Trying” message, followed by a “183 Session Progress” and a “180 Ringing”.

It looks like the differences are that when Caller ID is on, the INVITE header changes:

  • The “From” header takes on the caller’s phone number (but the name stays set to “PSTN”)
  • The “Remote-Party-ID” header changes to take on the caller’s phone number (instead of the trunk username I set, “pstntrunk”)
  • The SPA sends a HTTP DIGEST authentication (as it’s registering successfully, I expect the password is correct).
  • The “To” header remains the same, keeping the trunk’s phone number

How can I get FreePBX to accept the caller ID data (and the SPA), instead of throwing up a bunch of “no matching endpoint” errors?

My incoming routing rule is set to CID Any, DID Any. If I remember correctly, it also works with the DID set to the trunk’s PSTN number, but I can’t be certain. In any case, it didn’t get caller ID working.

Thanks.

PS: I do have a Dialplan configured in the SPA’s PSTN Line settings. It’s dialplan 2, and the PSTN-to-VoIP dialplan is set to default to it:

(S0<:[email protected]>)

I’ve solved this by using the configuration guide on www.2i2o.com to set up the SPA, using a chan_sip endpoint.

Chan_pjsip seems to not be a fan of acting as the receiving end for an SPA’s PSTN trunk, but it’s happy to serve the ATA side.

@philpem Quick correction. It’s an L not an I so it’s www.2l2o.com where these instructions live :slight_smile:

Hello dears, sorry for back this post too late and sorry for my english.

@philpem, i have a same problem here, can you explain in details how to do configuration?

I access the link you posted before, but appear not working properly.

Thanks, best regards.

Me too, did you manage to solve the problem?

Edit: go to PSTN Line and set Proxy to: frepbx_ip_address:5160

As discussed here, It will work with a pjsip trunk if you set “Authentication” and Registration" to “none” in pjsip trunk settings and set the SPA´s IP address in the Match (Permit) field in the advanced tab.

Then you set “Register” to “no” in the PSTN Line section of the SPA.

But it would be insecure unless both the FreePBX box and the SPA are in the same network.