[SOLVED] PJSIP outbound registration

I am using Asterisk 13.13.1 with PJSIP (2.5.5) on CentOS 7.3, all inbound provider ip addresses are defined in realtime.
As sugested by the documentation, outbound ip addresses are defined in pjsip.conf.
Although in the following link it is suggested that realtime should be possible now PJSIP, sorcery, realtime & res_pjsip_phoneprov_provider: phoneprov objects in realtime db?
Inbound works like a charm, though my outbound peers do not seem to register at all.
All this worked without a hitch with sip.conf, so I must be missing something in the convertion to pjsip.conf.
I studied similar cases, but fail to see what I am doing wrong.
Some feedback would be much apreciated as I would hate to have to switch back to sip.

asterisk -rx “pjsip show endpoints” returns the following below, which does not look OK to me as there is no aor, identiy or match section listed.

Endpoint: PSTN_provider_OUT Unavailable 0 of inf
Transport: UDP udp 0 0 0.0.0.0:5060

I am using ip based authentication, so there is no “registration” or “auth” section.

pjsip.conf

[general]
useragent=my-user-agent

[UDP]
type=transport
protocol=udp
bind=0.0.0.0:5060
tos=ef
cos=5

[WebRTC]
type=transport
protocol=wss
bind=0.0.0.0:8089
cert_file=/etc/asterisk/keys/asterisk.crt
priv_key_file=/etc/asterisk/keys/asterisk.key

; Outbound peers should not be in realtime.
[PSTN_provider_OUT]
type=aor
contact=sip:1.2.3.4:5060

[PSTN_provider_OUT]
type=endpoint
context=from-internal
aors=PSTN_provider_OUT
transport=UDP
disallow=all
allow=alaw

[PSTN_provider_OUT]
type=identify
endpoint=PSTN_provider_OUT
match=1.2.3.4

sorcery.conf

[res_pjsip] ; Realtime PJSIP configuration wizard
endpoint=config,pjsip.conf,criteria=type=endpoint ; Load outbound addresses from configuration file.
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts

[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips

I don’t understand exactly what your problem is. Your post is about outbound registration but you said you don’t have a “registration” section which is for outbound registration. Do you need outbound registration? If so the wiki[1] has an example. As well you’ve configured things to use realtime for AORs, identify, and other types but you have some configured in pjsip.conf which would not be used.

[1] https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples

Sorry for the confusion, I think I frased the question incorrectly due to all the experimenting I have been doing.
Simply put , I would like to know the following
How do I configure an ip address from my provider for outbound with ip based authentication in realtime pjsip ?

The following is my train of thought that led me to pose the question as above.

My provider allows me to dial out through a number of specific ip addresses, authentication on their side is based upon my servers ip address so there is no user/pass combination to enter.
Previously with sip.conf I created a peer and this would register with the provider (hence registration) and then I would be able to dial out using that peer.

As I recently moved to PJSIP and I configured all my provider peers to realtime.
Inbound traffic works like a charm, only when I wanted to dial out did I notice that this no longer works.

After some research, the documentation indicated that outbound is not possible using realtime, so that is why I moved this to pjsip.conf.
As what I understood from the documentation and similar cases that I found when ip authentication is used, there should be no “registration” and “auth” sections in pjsip.conf.

You can use outbound with realtime. What do you have in the database? As well in order to move to pjsip.conf you need to remove the mappings in sorcery.conf, or it will still look in the database.

I don’t have anything in the database atm, but I will have a go at putting it back there.
Due to your comment I see that I am only pulling endpoint from pjsip.conf, I should also have had identify and aor pull from both pjsip.conf and realtime.

But as you indicate outbound should be possible from realtime, I will put everything back in realtime.

I will first give that a try based upon what I intended to pull from pjsip.conf.

I have reconfigured outbound for realtime and I performed a call with debug information as follows
core set verbose 4
core set debug 4
pjsip set logger on

Communication seems to be on the correct ip/port, so there might be an issue with the RTP handshake.

An outbound call is started and there is communication with the provider, but the call is interupted with :

[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Response is 603 Decline
[Jan 17 16:04:43] DEBUG[21332][C-00000003] channel.c: Hanging up channel ‘PJSIP/PSTN_IP_O0001-00000002’
[Jan 17 16:04:43] VERBOSE[21332][C-00000003] app_dial.c: Everyone is busy/congested at this time (1:0/0/1)

I will post the call logs, but I first need to obfuscate the results and that will take some time to double check I do not mis anything.

[Jan 17 16:04:42] VERBOSE[21332][C-00000003] pbx.c: Executing [C@C-Node:79] Dial(“PJSIP/PSTN_IP_00005-00000001”, “PJSIP/EXTSTRING.DIALNUMBER@PSTN_IP_O0001,20,gm(PJSIP/PSTN_IP_00005-00000001-1)U(H-CALLED^PJSIP/PSTN_IP_00005-00000001^1663^/dir/dir/call-01/dir/agents/agentpiep.wav)”) in new stack
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Reusing ODBC handle 0x20f5fc0 from class ‘my-pjsip’
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM ps_endpoints WHERE id = ?
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Parameter 1 (‘id’) = ‘PSTN_IP_O0001’
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Releasing ODBC handle 0x20f5fc0 into pool
[Jan 17 16:04:42] DEBUG[21326] res_sorcery_realtime.c: Filtering out realtime field ‘disallow’ from retrieval
[Jan 17 16:04:42] DEBUG[21326] res_sorcery_realtime.c: Filtering out realtime field ‘external_media_address’ from retrieval
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [1800] in [0, 4294967295] gives 1800
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [90] in [0, 4294967295] gives 90
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Reusing ODBC handle 0x20f5fc0 from class ‘my-pjsip’
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM ps_aors WHERE id = ?
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Parameter 1 (‘id’) = ‘PSTN_IP_O0001’
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Releasing ODBC handle 0x20f5fc0 into pool
[Jan 17 16:04:42] DEBUG[21326] config.c: extract double from [3.0] in [-inf, inf] gives 3.000000
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [60] in [0, 4294967295] gives 60
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [3600] in [0, 4294967295] gives 3600
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [7200] in [0, 4294967295] gives 7200
[Jan 17 16:04:42] DEBUG[21326] config.c: extract double from [3.0] in [-inf, inf] gives 3.000000
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 4294967295] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract uint from [0] in [0, 86400] gives 0
[Jan 17 16:04:42] DEBUG[21326] config.c: extract double from [3.000000] in [-inf, inf] gives 3.000000
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Reusing ODBC handle 0x20f5fc0 from class ‘my-pjsip’
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM ps_contacts WHERE id LIKE ? ORDER BY id
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Parameter 1 (‘id LIKE’) = ‘PSTN_IP_O0001;@%’
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Releasing ODBC handle 0x20f5fc0 into pool
[Jan 17 16:04:42] VERBOSE[21332][C-00000003] app_dial.c: Called PJSIP/EXTSTRING.DIALNUMBER@PSTN_IP_O0001
[Jan 17 16:04:42] DEBUG[21326] rtp_engine.c: Using engine ‘asterisk’ for RTP instance ‘0x7f071c02d820’
[Jan 17 16:04:42] DEBUG[21326] res_rtp_asterisk.c: Allocated port 16652 for RTP instance ‘0x7f071c02d820’
[Jan 17 16:04:42] DEBUG[21326] res_rtp_asterisk.c: Creating ICE session [::]:16652 (16652) for RTP instance ‘0x7f071c02d820’
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_odbc.c: Reusing ODBC handle 0x20f5fc0 from class ‘my-pjsip’
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 ICE session created, comp_cnt=2, role is Unknown agent
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM musiconhold WHERE name = ?
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_config_odbc.c: Parameter 1 (‘name’) = ‘PJSIP/PSTN_IP_00005-00000001-1’
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_odbc.c: Releasing ODBC handle 0x20f5fc0 into pool
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_musiconhold.c: Scanning ‘/dir/dir/call-01/dir/dir/calling.moh’ for files for class ‘PJSIP/PSTN_IP_00005-00000001-1’
[Jan 17 16:04:42] VERBOSE[21332][C-00000003] res_musiconhold.c: Started music on hold, class ‘PJSIP/PSTN_IP_00005-00000001-1’, on channel ‘PJSIP/PSTN_IP_00005-00000001’
[Jan 17 16:04:42] DEBUG[21332][C-00000003] channel.c: Scheduling timer at (50 requested / 50 actual) timer ticks per second
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 0 added: comp_id=1, type=host, foundation=H8b313ad0, addr=fe80::46a8:42ff:fe1b:93d7:16652, base=fe80::46a8:42ff:fe1b:93d7:16652, prio=0x7effffff (2130706431)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 1 added: comp_id=1, type=host, foundation=H8b313ad1, addr=fe80::46a8:42ff:fe1b:93d8:16652, base=fe80::46a8:42ff:fe1b:93d8:16652, prio=0x7effffff (2130706431)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 2 added: comp_id=1, type=host, foundation=Hbcc8b80a, addr=111.EXT.IP.10:16652, base=111.EXT.IP.10:16652, prio=0x7effffff (2130706431)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 3 added: comp_id=1, type=host, foundation=Hc0a80065, addr=192.168.0.101:16652, base=192.168.0.101:16652, prio=0x7effffff (2130706431)
[Jan 17 16:04:42] DEBUG[21326] rtp_engine.c: RTP instance ‘0x7f071c02d820’ is setup and ready to go
[Jan 17 16:04:42] DEBUG[21326] acl.c: Not an IPv4 nor IPv6 address, cannot get port.
[Jan 17 16:04:42] DEBUG[21326] res_rtp_asterisk.c: Setup RTCP on RTP instance ‘0x7f071c02d820’
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 4 added: comp_id=2, type=host, foundation=H8b313ad0, addr=fe80::46a8:42ff:fe1b:93d7:16653, base=fe80::46a8:42ff:fe1b:93d7:16653, prio=0x7efffffe (2130706430)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 5 added: comp_id=2, type=host, foundation=H8b313ad1, addr=fe80::46a8:42ff:fe1b:93d8:16653, base=fe80::46a8:42ff:fe1b:93d8:16653, prio=0x7efffffe (2130706430)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 6 added: comp_id=2, type=host, foundation=Hbcc8b80a, addr=111.EXT.IP.10:16653, base=111.EXT.IP.10:16653, prio=0x7efffffe (2130706430)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Candidate 7 added: comp_id=2, type=host, foundation=Hc0a80065, addr=192.168.0.101:16653, base=192.168.0.101:16653, prio=0x7efffffe (2130706430)
[Jan 17 16:04:42] DEBUG[21326] pjproject: icess0x7f071c0 Destroying ICE session 0x7f071c02a878
[Jan 17 16:04:42] DEBUG[21326] pjproject: ice_session.c ICE session 0x7f071c02a878 destroyed
[Jan 17 16:04:42] DEBUG[21326] res_pjsip_t38.c: Not creating outgoing SDP stream: T.38 not enabled
[Jan 17 16:04:42] DEBUG[21326] res_pjsip_session.c: Method is INVITE
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Reusing ODBC handle 0x20f5fc0 from class ‘my-pjsip’
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM ps_domain_aliases WHERE id = ?
[Jan 17 16:04:42] DEBUG[21326] res_config_odbc.c: Parameter 1 (‘id’) = ‘222.PROV.IP.190’
[Jan 17 16:04:42] DEBUG[21326] res_odbc.c: Releasing ODBC handle 0x20f5fc0 into pool
[Jan 17 16:04:42] DEBUG[21326] res_pjsip/pjsip_message_ip_updater.c: Re-wrote Contact URI host/port to 111.EXT.IP.10:5060
[Jan 17 16:04:42] VERBOSE[21326] res_pjsip_logger.c: <— Transmitting SIP request (949 bytes) to UDP:222.PROV.IP.190:5060 —>
INVITE sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190 SIP/2.0
Via: SIP/2.0/UDP 111.EXT.IP.10:5060;rport;branch=z9hG4bKPj8816e271-e349-4ee6-8283-3aed120f8495
From: “DIALSTRING” sip:DNIS@111.EXT.IP.10;tag=98c3c1f4-6bb9-4d6a-9e7a-8a8080966fdf
To: sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190
Contact: sip:asterisk@111.EXT.IP.10:5060
Call-ID: aa70aa9b-ad3d-4e1b-9aea-631eeca95c32
CSeq: 2921 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.13.1
Content-Type: application/sdp
Content-Length: 239

v=0
o=- 958255096 958255096 IN IP4 111.EXT.IP.10
s=Asterisk
c=IN IP4 111.EXT.IP.10
t=0 0
m=audio 16652 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

[Jan 17 16:04:42] DEBUG[21326] res_pjsip_session.c: Source of transaction state change is TX_MSG
[Jan 17 16:04:42] DEBUG[21332][C-00000003] channel.c: Channel PJSIP/PSTN_IP_00005-00000001 setting write format path: slin -> alaw
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_musiconhold.c: PJSIP/PSTN_IP_00005-00000001 Opened file 0 ‘/dir/dir/call-01/dir/dir/calling.moh/calling’
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_rtp_asterisk.c: Difference is 2256, ms is 302
[Jan 17 16:04:42] DEBUG[21332][C-00000003] res_rtp_asterisk.c: Using IPv6 mapped address 185.45.44.155:17224 for STUN
[Jan 17 16:04:42] DEBUG[21332][C-00000003] stun.c: Scrambled STUN packet length (got 57797, expecting 128)
[Jan 17 16:04:42] DEBUG[21332][C-00000003] stun.c: Inconsistent Attribute (length 8228 exceeds remaining msg len 128)
[Jan 17 16:04:43] DEBUG[57300] res_pjsip/pjsip_message_ip_updater.c: Re-wrote Contact URI host/port to 111.EXT.IP.10:5060
[Jan 17 16:04:43] VERBOSE[57300] res_pjsip_logger.c: <— Transmitting SIP request (949 bytes) to UDP:222.PROV.IP.190:5060 —>
INVITE sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190 SIP/2.0
Via: SIP/2.0/UDP 111.EXT.IP.10:5060;rport;branch=z9hG4bKPj8816e271-e349-4ee6-8283-3aed120f8495
From: “DIALSTRING” sip:DNIS@111.EXT.IP.10;tag=98c3c1f4-6bb9-4d6a-9e7a-8a8080966fdf
To: sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190
Contact: sip:asterisk@111.EXT.IP.10:5060
Call-ID: aa70aa9b-ad3d-4e1b-9aea-631eeca95c32
CSeq: 2921 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.13.1
Content-Type: application/sdp
Content-Length: 239

v=0
o=- 958255096 958255096 IN IP4 111.EXT.IP.10
s=Asterisk
c=IN IP4 111.EXT.IP.10
t=0 0
m=audio 16652 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

[Jan 17 16:04:43] VERBOSE[57300] res_pjsip_logger.c: <— Received SIP response (439 bytes) from UDP:222.PROV.IP.190:5060 —>
SIP/2.0 603 Decline
Via: SIP/2.0/UDP 111.EXT.IP.10:5060;rport=5060;branch=z9hG4bKPj8816e271-e349-4ee6-8283-3aed120f8495;received=111.EXT.IP.10
From: “DIALSTRING” sip:DNIS@111.EXT.IP.10;tag=98c3c1f4-6bb9-4d6a-9e7a-8a8080966fdf
To: sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190;tag=a6dee7a96244e64496b4fcd3772cfa03.2767
Call-ID: aa70aa9b-ad3d-4e1b-9aea-631eeca95c32
CSeq: 2921 INVITE
Server: MS Lync
Content-Length: 0

[Jan 17 16:04:43] DEBUG[57300] res_pjsip/pjsip_distributor.c: Searching for serializer on dialog dlg0x7f071c00f5e8 for Response msg 603/INVITE/cseq=2921 (rdata0x7f0728003e98)
[Jan 17 16:04:43] DEBUG[57300] res_pjsip/pjsip_distributor.c: Found serializer pjsip/outsess/PSTN_IP_O0001-0000064c on dialog dlg0x7f071c00f5e8
[Jan 17 16:04:43] VERBOSE[21326] res_pjsip_logger.c: <— Transmitting SIP request (473 bytes) to UDP:222.PROV.IP.190:5060 —>
ACK sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190 SIP/2.0
Via: SIP/2.0/UDP 111.EXT.IP.10:5060;rport;branch=z9hG4bKPj8816e271-e349-4ee6-8283-3aed120f8495
From: “DIALSTRING” sip:DNIS@111.EXT.IP.10;tag=98c3c1f4-6bb9-4d6a-9e7a-8a8080966fdf
To: sip:EXTSTRING.DIALNUMBER@222.PROV.IP.190;tag=a6dee7a96244e64496b4fcd3772cfa03.2767
Call-ID: aa70aa9b-ad3d-4e1b-9aea-631eeca95c32
CSeq: 2921 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 13.13.1
Content-Length: 0

[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Source of transaction state change is RX_MSG
[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Received response
[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Response is 603 Decline
[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Received response
[Jan 17 16:04:43] DEBUG[21326] res_pjsip_session.c: Response is 603 Decline
[Jan 17 16:04:43] DEBUG[21332][C-00000003] channel.c: Hanging up channel ‘PJSIP/PSTN_IP_O0001-00000002’
[Jan 17 16:04:43] VERBOSE[21332][C-00000003] app_dial.c: Everyone is busy/congested at this time (1:0/0/1)

There’s nothing evident of why it would fail, but the remote side is sending back a 603 for some reason. Your configuration (from the config file one) was simple enough. I can’t say why it is failing.

Thanks for looking Joshua, I will try changing a few things around and switch back to realtime.
Unfortunately the tech guy at the provider end is unavailable atm.

SOLVED
Our outbound provider changed the ip ranges and forgot to tell me.

Joshua apologies to have bothered you with that, I really was under the impression that it was all my fault.

No problem at all! Glad to hear you got it working.