Uploaded image for project: 'FreePBX'
  1. FreePBX
  2. FREEPBX-17803

Allow changing of Endpoint identification matching priority in PJSIP



    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: Asterisk SIP Settings, Core
    • Labels:
    • ToDo:


      If you go to the page at https://blogs.asterisk.org/2018/02/07/identifying-endpoint-pjsip/ it states this:

      Endpoint identification matching priority

      With several endpoint identifiers available, res_pjsip asks each identifier in turn if can match an endpoint with the request. The first endpoint identified handles the request message. It is possible that more than one endpoint identifier could identify an endpoint for the request. To bring some predictability to which endpoint is recognized, you can specify the order endpoint identifiers check the request with the global endpoint_identifier_order option.

      The endpoint_identifier_order option is a comma separated list of endpoint identifier names. The order of the list is the specified order the named identifiers check the request. Any named identifiers not listed are checked last in the order they are registered. Any identifiers that have no name are checked first in the order they are registered.

      If you issue the CLI command “pjsip show identifiers” you get the list of endpoint identifiers available on your system in the order they are checked. You can list any of the named endpoint identifiers on the endpoint_identifier_order option.

      *CLI> pjsip show identifiers
      Identifier Names:
      name not specified

      [END QUOTE]

      In fact when I run “pjsip show identifiers” I get the output shown above.  It is the order in which they are checked that I believe causes so many problems in moving from Chan SIP to PJSIP.  Most people do not want to match on IP address, and checking the IP address first is what probably leads to situations such as the one I first described in FREEPBX-17738, where I noted that if you try to have both a PJSIP trunk and a PJSIP extension coming from the SAME remote IP address, the PJSIP extension stops working.  In that ticket, Rob Thomas said this:

      "On re-reading, I think I may have figured out what you've done. You've got a phone on IP that's talking to server A on port 5060 as an extension You've then set up a trunk on port port 5060 so that all calls coming from IP address are treated as a trunk call.

      Easiest way around that is to use chan_sip for one (port 5160) and pjsip for the other (5060). Then your machine will be able to differentiate."

      However to me that seems like an admission of defeat.  If you want PJSIP to eventually replace Chan SIP altogether, there has to be a way to deal with situations like this.  And my suspicion is that it is this "IP matching first" policy that is the cause of all the problems, possibly even the problems that are being encountered by those trying to get more than one Google Voice account (using the new "sort of SIP" protocol used by Google Voice) to work in Asterisk.  It would seem to me that you want endpoints (and trunks) to authenticate using username (or auth_username, not sure what the difference is) first.  This will not only help keep trunks and extensions separate, but also help differentiate multiple extensions coming from the same IP address, if that is an issue.

      So basically what I'm asking for here is a setting in the PJSIP settings that lets you reorder the Endpoint identification matching priority in Asterisk, so that users can set it to username or auth_username as the first thing to check.  Now I may be barking up the wrong tree here, in that I have very little experience with PJSIP, but still it does not seem to me like using PJSIP for your extensions and Chan_SIP for your trunks is a viable long term solution, and it also doesn't address what happens if you want to have multiple endpoints at the same IP address.  I don't know whose bright idea it was to try to reuse connections that come in from the same IP address but judging from the number of problems it seems to be causing, I'm not thinking it was a good idea.  Of course the Asterisk people will try to say this is not an issue and there are ways to make it work, but I'm not using raw Asterisk, I'm using FreePBX, and this stuff should be easy (or at least as easy as it was with Chan SIP).  Of course in Chan SIP you could distinguish between extensions by using separate ports (put extension 100 on port 5060 and extension 101 on port 5061) but PJSIP apparently doesn't let you do that, either.

        Gliffy Diagrams


            Issue Links



                • Assignee:
                  jphilip Philip Joseph
                  Cam Cam
                • Votes:
                  0 Vote for this issue
                  8 Start watching this issue


                  • Created:


                    Error rendering 'slack.nextup.jira:nextup-jira-plus-status'. Please contact your Jira administrators.