No incoming calls

I might be wrong here, but I think this is failing because of how you defined your trunk. SPA3102 is sending “pstn” as username, but your trunk is not correctly configured for that username.

In order for me to help you, please provide your trunk definition on FreePBX and your FXO configuration and dial plan on SPA3102

Unfortunately, my 3102 is on an old system (chan_sip only) and I’ve never used pjsip in a Registration Receive scenario. As a guess, try setting Match (Permit) for the trunk to 192.168.1.151 and reloading (or restarting) Asterisk. Also, make sure that you have a default (any DID) Inbound Route, in case there is an issue there.

If no luck, post screenshots of the pjsip trunk settings (General and Advanced) and maybe we can spot something. Otherwise, trying chan_sip is a possibility.

Hi, Many thanks for your assistance, I have attached the requested screen shots

The redacted text is my PSTN line number.

Sorry, I meant the FXO registration settings. Also, there is a high probability that you will get better result with a CHAN_SIP trunk instead of CHAN_JSIP in this particular case.

Hi, Here are both the PSTN & Line 1 registration setting.

As I can see, the username pstn seems to be configured correctly both on the SPA and on the trunk definition, but for some reason FreePBX doesn’t recognize it, from the fact that you get the error that there is no endpoint called pstn. Have you tried setting the trunk as a CHAN_SIP trunk instead of PJSIP?

In the Inbound Route setting, the CallerID Number field should be blank. When you put something there, it means that only calls from the number you specify should use that route.

Also, until you get this working, don’t push your luck by routing the calls back to the 3102 itself – use another extension that you have tested (by calling it from ext. 105 or from a third extension) and is known to receive incoming calls properly.

If you still have trouble, please post screenshots of the 3102 Dial Plans and the PSTN-To-VoIP Gateway Setup, and the Advanced tab of the pjsip Settings for the trunk.

Ok I have changed to a SIP trunk (screen shots attached), but now cant get the PSTN (SPA3102) to register. I have also changed the CID on the Inbound route to blank as per Stewrat1’ s suggestion.

Just to say - I really

appreciate the support that you guys are giving me, thanks.

I have also changed the “set Destination” on the “Inbound Route” to extension 100

Maybe you shouldn’t have switched to chan_sip before posting the rest of your pjsip settings. But anyhow, here are my chan_sip settings:

Of course, your user and trunk names will be different.

Assuming that you are using the default ports (pjsip on 5060 and chan_sip on 5160), in the 3102 you need to change Proxy to 192.168.1.175:5160
Also, if this is your first chan_sip trunk or extension, you’ll need to permit UDP port 5160 in whatever firewall you may be running on the PBX.

If you still can’t register, see if anything gets logged for the attempts. If not, it’s probably a firewall issue.

Or, post your pjsip and 3102 details as previously requested and we’ll try to debug that.

You Guys are fantastic, I now have incoming and outgoing calls working. Thank you so much.

Best regards

Peter

I’m glad that you got it working. Please post the solution, to help the next user with a similar issue.

I think I know what your problem is with a registration receive PJSIP trunk.

In short, inbound invites will fail to authenticate if the user portion in the from header of the invite that’s coming in doesn’t equal your trunk name in your PJSIP trunk.
That’s because pjsip is matching the endpoint to the username in the from header. As you have your 078603xxx number in the from header, but your trunk username is pstn, there is no match and your call fails.
PJSIP unfortunately does not currently support using a registered IP address to do inbound IP based matching.

The are two solutions, but each one requires adding a parameter in custom.conf files.

Solution 1:
Force your PJSIP trunk to not authenticate incoming invites on the user portion in the invite from header, but on authentication username of the trunk, which is “pstn” in your example.

You do this by adding the parameter identify_by=auth_username to pjsip.endpoint_custom_post.conf with your endpoint (trunk) name in square brackets.
Like this:

[pstn](+)
identify_by=auth_username

Solution 2:
Look for a setting on your gateway that’s equivalent to the parameter “from user” on Asterisk. Set this to your trunk name.
Then calls will work but all show the same CallerID.
To fix that make sure to send PAI or RPID header and set your PJSIP trunk to trust remote party ID, which it doesn’t do by default.
For this you need to add parameter trust_id_inbound in pjsip.endpoint_custom_post.conf:

[pstn](+)
trust_id_inbound=yes

There are feature requests on the bug tracker to add those options to the GUI.
Vote them up if you would like them to happen:
https://issues.freepbx.org/projects/FREEPBX/issues/FREEPBX-17158
https://issues.freepbx.org/projects/FREEPBX/issues/FREEPBX-17157

Best would be if Digium changed PJSIP to support using a registered IP address to do inbound IP based matching.

1 Like

In the OP’s case (gateway and PBX on the same LAN), a simple solution for pjsip would be to have the gateway IP address be static or (static DHCP). You could then set it up like a ‘wholesale’ trunk, no registration, no authentication, put the gateway address in the Match (Permit) field, put the PBX address in the gateway’s VoIP Access List.

@avayax, assuming that the OP tried my suggestion for the Mach (Permit) field and it didn’t help, do you know whether that gets ignored when Registration Receive is set?

The Match (Permit) setting gets ignored with Registration Receive.

It’s normally part of the identify section of an endpoint, but endpoints receiving registration have none.
The identify configuration enables IP address matching against an endpoint.
But PJSIP can’t use a registered IP address to do inbound IP based matching, therefore no need for an identify for registration receivers.

For calls from a trunking provider that you have registered to, the From user may be different every time,
so you want to match against IP address instead of From user, and that is what the Identify section and Match (Permit) field is for.

That’s also an option.
With the gateway on static IP there is no need for registration. The trunk can then still be set to authenticate invites in whatever directions the OP wants, but he won’t encounter the problem he is describing, as matching will be done on IP address.
If you set the PJSIP trunk to not register, an identify section and a Match field will be set automatically.

There is a default order in PJSIP by which endpoint identifiers are given priority.
It’s:
endpoint_identifier_order=ip,username,anonymous,auth_username

Many thanks for the explanation.

We really need a ‘pjsip cookbook’ or maybe ‘pjsip for dummies’. The drumbeat is “Use pjsip; chan_sip is deprecated”, but few know how it works.

In my own situation, with the 3102 at a remote location on a dynamic IP, Registration Receive is mandatory. Your ‘Solution 2’ won’t work on a 3102, because the only way to not put the calling number in the From header is to not have caller ID at all. Solution 1 would work fine, but not knowing that there are ‘secret’ pjsip parameters not exposed in the GUI, I would have given up and switched to chan_sip. Of course, when people do that, they join the crowd that believes that pjsip is not ready for prime time.

2 Likes

True true true, been looking a long time for proper PJSIP documentation.

I use this documentation:

2 Likes

That’s true.

I have only recently ventured into starting with PJSIP, but I am liking it, so whatever problems I encounter I am commited playing a part in fixing them.
The developers are fairly responsive on the FreePBX and Asterisk issue trackers, so if you bring things there they get addressed.

1 Like