Freepbx PJSIP Trunk register fails

Hello, I am trying to configure a PJSIP trunk on freepbx framework 14.0.13.28 and an Asterisk 14.7.8.

After the first register attempt my provider sends a 401 (normal) and asks for authorization. But my freepbx tries to re register with the initial Cseq (it should be a new one) so there is no authorization header. So it seems that my freepbx does not follow up on the first 401 but tries to initially register again and again and the registration fails in the end.

The weird thing is it used to work for a while and then just stopped.

Can anyone tell me maybe how to troubleshoot the handling of my freepbx with the first 401 response please? Or maybe even what the problem could be? any help is greatly appreciated. Thank you!

If your public IP address is not static, it may have changed. Confirm that Asterisk SIP Settings -> External Address is correct. If you change this, you must restart (not just reload) Asterisk.

Otherwise: Almost certainly, Asterisk is not seeing the 401 or is rejecting it.

At the Asterisk command prompt, type
pjsip set logger on
and see whether the 401 appears in the normal Asterisk log. It it does, there is likely an error message about its rejection. If the 401 does not appear, check whether it is seen by a tcpdump running on the Asterisk machine. If not there, either, it’s being blocked by something in your network infrastructure, or the outgoing request was malformed. If tcpdump does see the 401, it’s being blocked by the FreePBX firewall (very strange since replies are normally not filtered).

The REGISTER request (as shown by the pjsip logger) has a Via header, which must either contain Asterisk’s correct public IP address and port, or have the rport parameter. If this is wrong, check that in Asterisk SIP Settings, External Address and Local Networks are correctly set.

Also, make sure that any SIP ALG is turned off in your router or firewall.

If you still have trouble, please post: Cloud or on-site? If cloud, which platform?
For on-site systems: Physical or virtual? If virtual, which platform? If not using bridged networking, please explain. Router/firewall make/model? Any special VoIP-related settings? Does it have a public IP on its WAN interface? If not, please explain (modem is configured as router, ISP does NAT, etc.)

Was this installed from the Distro ISO? If not, how did you build it?

Anything else that may be relevant (Country, ISP, Modem make/model, trunking provider, etc.)?

Thank you very much for the fast response. I can see a

[2020-04-21 08:17:29] WARNING[15692] res_pjsip_outbound_registration.c: No response received from ‘sip:sipconnect.ipfonie.de’ on registration attempt to ‘sip:[email protected]’, retrying in ‘300’

I am using sngrep on the asterisk an I can see that the provider is sending me back a 401. I will check tcpdump next and then the firewall, as you suggest to do. Thank you again

sngrep works like tcpdump. It’s before the firewall for incoming packets and after for outgoing.
Does pjsip logger show the 401? If not, see whether turning off the FreePBX firewall makes a difference. If the logger does show the 401, paste the relevant section of the Asterisk log (including request and response) at https://pastebin.freepbx.org and post the link here.

Probably not the problem here, but know that Asterisk 14 is EOL. Best to be on 16 now.
https://wiki.freepbx.org/display/PPS/Changing+Major+Asterisk+Versions+on+the+Fly

Hey, disabling the responsive firewall for pjsip allowed the trunk to register. Thank you so much for your advice! I know where to continue from here

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.