Migration of SIP trunk to PJSIP

Hello to all,
I’d like to convert my old SIP trunk into PJSIP.
So in SIP setting I moved ports between SIP and PJSIP so PJSIP using 5060 now.
I configured one trunk and It’s working but this another trunk si cursed for me.
Here is a SIP configuration:

2

I tried rewrite it into PJSIP trunk but it still sending me back this error:

 ERROR[3356]: res_pjsip_outbound_registration.c:1389 sip_outbound_registration_regc_alloc: Invalid client URI 'sip:username:secret@<ip_of_provider>:5060/username' specified on outbound registration 'Trunk_name'
[2022-02-24 12:18:36] ERROR[24842]: res_sorcery_config.c:422 sorcery_config_internal_load: Could not create an object of type 'registration' with id 'Trunk_name' from configuration file 'pjsip.conf'

My configuration in PJSIP looks like:

General:
Username: Trunk_name
Auth username: username
Secret: secret
Authentication: Outbound
Registration:  Send
SIP server: <ip_of_provider>
SIP server port: 5060

Advanced:
DTMF Mode:                        Auto
Send Line in Registration:    Yes 
Send Connected Line:          No
Permanent Auth Rejection:   No
Forbidden Retry Interval:      30
Fatal Retry Interval               30
General Retry Interval          60
Expiration                             3600
Max Retries                         10000
Qualify Frequency                60
Outbound Proxy                   sip:<ip_of_provider>
User = Phone                        No
Contact User                         username
From Domain                        sip:<ip_of_provider>
From User                             username
Client URI                             sip:username:secret@<ip_of_provider>:5060/username
Server URI                            sip:username@<ip_of_provider>:5060
Media Address 
AOR                                      username
AOR Contact                         sip:username:secret@<ip_of_provider>:5060
Match (Permit) 
Support Path                          No
Support T.38 UDPTL              No
T.38 UDPTL Error Correction None 
T.38 UDPTL NAT                    No
T.38 UDPTL MAXDATAGRAM 
Fax Detect                              No
Trust RPID/PAI                       No
Send RPID/PAI                       No 
Send Private CallerID Information    No
Match Inbound Authentication           Default
Inband Progress                     No
Direct Media                           No
Rewrite Contact                      No
RTP Symmetric                       Yes
Media Encryption                     None
Force rport                                Yes
Message Context

Honestly I only know that I should set Authentication to Outbound but don’t know what to fill into advanced part of setting.
Can anyone give me a clue where to place which parameter?
Thanks a lot

Almost certainly type=friend was wrong in chan_sip (it usually is), in which case “Trunk_name” only has local significance (and a means of entry for an attacker). I think username should be username in the PJSIP configuration.

The message is correct. Addresses of record do not contain authentication fields. They definitely have no use, although I’m still checking whether they are forbidden. [ The password turns out to be syntactically valid, although probably wrong, but I overlooked the “/username”, which is totally bogus. ]

Needs to be the actual username/authname.

This is wrong. This format is completely unacceptable. It needs to be an actual URI like this: sip:username@<ip_of_provider>:5060

Also incorrect, needs to have the ;lr tag on the end so it should look like this: sip:<ip_of_provider>\;lr (since you need to escape ; in Asterisk)

Incorrect and this would have been incorrect for Chan_SIP. It is just the domain so it would be: <ip_of_provider> only, the domain. No URI.

This needs to be a URI i.e. sip:username@<ip_of_provider>:5060

This is a URI. However I’d agree that having the full form of the userinfo element is unlikely to be right.

The chan_sip configuration doesn’t seem to have a proxy at all. I think the OP has just tried to set all the parameters on the form without knowing whether they are really needed. Although almost everything these days uses loose routing, I don’t think you can definitely say that it must always be specified if a proxy is needed.

I checked and, although unlikely to be right, there is no prohibition on having the full form of the userinfo present, but the “/username” is totally wrong

In Chan_PJSIP the outbound_proxy setting needs to have ;lr on it. That is how it works; it is documented as such. Not having the ;lr is wrong in the outbound_proxy is incorrect for Chan_PJSIP.

It’s an incorrect URI. You do not use : in the user part. The : is being used for specific things already.

I missed this one. userinfo and “@” are subject to a MUST NOT rule, which is mandatory. They should not be present.

IMO there is no need to discuss the complexities, because the chan_sip given is very simple.
Please set up the pjsip trunk with all settings at defaults except:

Trunk name: (as desired)
SIP Server: ip of provider
Username: username
Secret: secret
Context: from-trunk-custom
From User: username

Leave everything else blank and test. Report any errors and we can adjust from there.

Thank all of you!

I used what Stewart1 wrote, only with few changes. Outbound Proxy is mandatory so I type there what BlazeStudios wrote (sip:<ip_of_provider>;lr)

So now I can make outbound calls but not incoming calls.
Provider on it’s PBX see that I’m not registered.
So I need to register to provider PBX as like a endpoint (I’m an endpoint from it’s point of view)

So now I would like to know what I need to fill to register to provider as like a endpoint (or better, register in general cause I don’t think there is defference between registering like endpoint or trunk from my point of view)

Thank you for educate me

I did some tests and compare behavior between SIP and PJSIP against this trunk.
And PJSIP has act as like a SIP without register string (wroted in first article). I mean when I delete register string in SIP, I still can make outgoing calls but can’t accept incoming calls. Now I have same behavior with PJSIP - Outgoing is OK but Incoming is wrong and provider sees me as unregistered.
So what I suppose to need is transform this register string into PJSIP setting.
Has anyone know how please?

You are not reporting the errors that you get when you try to register.

Also, if this is not straightforward, specific information about the provider requirements will be needed, as just using the GUI should normally be sufficient for what seems to be a run of the mill service, albeit one not officially supporting PABXes. SIP does not care whether what is registering thinks it is a trunk or an extension.

FINALY!! IT WORKS!
Not as I expected, but it works and now I can call both ways.

So, configuration was really simple:

General:
Trunk Name: There could be anythink

PJSIP General:
Username: <username_given_by_provider>
Seceret: <secret_given_by_provider>
Authentication: Outbound 
Registration: Send
SIP Server: <ip_of_provider>

PJSIP Advanced:
From User: <username_given_by_provider>

Everything else left as default

All problem was in IP addres of my PBX:
Settings → Asterisk SIP Settings → General SIP Settings → NAT Setting → External Address
There I needed to place proper IP of my interface which is made only for connect with VoIP provider <ip_of_MY_FreePBX>.

BUT when I call from outside (e.g. from mobile phone) to my PBX, the call hit the from-pstn context with “s” extension. But I would expect here a <username_given_by_provider> (which is a number) or perhaps CallerID instead of “s”.
And I would like to fix that, that I can use my own context (I don’t have s in my context)

The incoming call is presented by:

<--- Received SIP request (961 bytes) from UDP:<ip_of_provider>:5060 --->
INVITE sip:s@<ip_of_MY_FreePBX>:5060;line=neco SIP/2.0
Via: SIP/2.0/UDP <ip_of_provider>:5060;branch=z9hG4bK69ff9fcf
Max-Forwards: 70
From: <sip:<My_mobile_phone_number>@<ip_of_provider>>;tag=as202a8b38
To: <sip:s@<ip_of_MY_FreePBX>:5060;line=neco>
Contact: <sip:<My_mobile_phone_number>@<ip_of_provider>:5060>
...etc.

<--- Transmitting SIP response (330 bytes) to UDP:<ip_of_provider>:5060 --->
SIP/2.0 100 Trying
...etc.

    -- Executing [s@from-pstn:1] Set("PJSIP/MY_TRUNK-00000023", "__DIRECTION=INBOUND") in new stack
        .
        .
        .
        .
        .etc.

So is there a way how to change it/fix it? Or it’s on providers site?

Thank you for replies

It would normally be whatever you put in Contact User, s is the default

Thank you David, you’re right (as always).

Now, it’s working completely fime.

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