Common SIP URI Issues
When transitioning from the chan_sip channel driver to chan_pjsip one of the items that can catch people off guard is the use of SIP URIs within PJSIP. This is because in chan_sip these are generated on your behalf based on different configuration options while in chan_pjsip we leave this up to the user. Let’s take a look at the two common problems people run into!
Could not create dialog to invalid URI
A URI is constructed out of a scheme and a hostname at a minimum. If you specify merely a hostname, such as “asterisk.org”, this will be considered invalid as PJSIP requires a scheme to be specified and does not automatically assume that it is sip. You would need to add “sip:” to the front resulting in “sip:asterisk.org” to turn it into a SIP URI. Note that there may be other log messages which convey this issue, so be sure to check both your console log at startup and at runtime to see if this is potentially a problem.
Request URI Does Not Contain User Portion
This is seen when people configure an “outbound_proxy” on either an endpoint, AOR, or outbound registration and do not have loose routing enabled. Loose routing is a parameter on the URI which instructs PJSIP to not change the request URI to that of the outbound proxy. This can be because of two issues:
Lack of Loose Routing In General
By default PJSIP does not enable loose routing on a SIP URI. It has to be explicitly done in the configuration by adding “;lr” to the SIP URI. Note though that if using a .conf file you may need slightly more due to the following issue.
Configuration File Comment
In configuration files prefixing a string with “;” indicates to the configuration parser that it is a comment and should be ignored. This is problematic for the loose routing URI parameter so you must escape it by placing “\” in front of it resulting “\;lr”.
Putting these together into a full example yields “sip:pbx.gtivoice.com\;lr”
This would configure the outbound proxy to be “pbx.gtivoice.com” and enable loose routing.