I am setting up a replacement install of FreePBX 18.104.22.168 and Asterisk 13.21.1 (replacing an older version) and thought I would try using PJSIP. But there are a couple of things that seem non-obvious.
First, I have one case where I have two extensions going to a two-line VoIP adapter (old Linksys PAP2). The first line is on the usual SIP port 5060, and the second is on port 5061. Using a Chan SIP extension, you can easily set those port numbers in the extension configuration. But in PJSIP, I cannot find any way to set the port number on a per-extension basis. Am I just not seeing it, or is there really no way to do this? And if not, how do you keep the extensions separate? I know you can give each account a separate extension number and password, but given the other problem I encountered as described in the next paragraph, I’m not sure that would be sufficient. Unfortunately, I’m unable to do a live test at the moment.
Second, is there some special trick you have to use to make both a trunk from another Asterisk server and an extension connect from the same remote IP address, without Asterisk getting confused and thinking that attempts by the extension to register are coming from the trunk, and rejecting them because the username and password don’t match the trunk’s username and password? When the extension tries to register you get an error such as “AOR ‘extension number’ not found for endpoint [trunk name]” or something to that effect. Remove the trunk, and the extension can register with no problem.
If these are not easy questions to deal with, I’ll just keep using Chan SIP, since I know that works. I had just thought that since PJSIP has been around for a while now, it might actually work without issues. I’m not real interested in spending any significant amount of time on debugging this, since I’m not convinced there’s any real advantage to using PJSIP over Chan SIP in my situation, but thought I’d at least ask before giving up on PJSIP in case I am missing something obvious.
I’m having the exact same problem with the trunk and extension with the same IP address. Have you found a workaround?
Possibly. In /etc/asterisk/pjsip_custom_post.conf try adding this line:
This appears to cause PJSIP to try to match the auth_username and then username before the IP address (by default it matches the IP address first). It still won’t let you put an extension on a different port, but it does let you have a trunk and extension coming from the same IP address. For multiple extensions, maybe just the fact that they have different auth_usernames (their extension number) is sufficient in PJSIP even if they are using the same port, but I have not had the opportunity to test that. If you do, please let me know if it works.
This changes how matching is done globally for all endpoints, but you can also change it per endpoint.
For PJSIP trunks there is now a GUI option:
Setting this alone might actually solve the OP’s problem.
If not, identify_by=auth_username can be set for each endpoint in
I just can’t think of any good reason NOT to change it globally. Under what circumstance would it ever be advantageous to match on the IP address first? I can think of no reasons to do it that way, and some very good reasons not do do it that way. Am I missing something here?
Plenty of people use trunks without username or password and rely on IP only.
Okay, good point, I had not thought of that. But still, many if not most trunks from service providers require a username and password and in some cases even registration, so it seems to me that for many users (those that do not have trunks that rely on IP address only) it would be better to match on auth_username or username rather than IP address.
Also, why can you set the matching for a trunk in the GUI, but not for an extension?
Try a feature request.
I opened one a while ago to expose the match option for trunks in the GUI, which was addressed and fixed.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.