PJSIP trunking. Trunk not established

Hi,

I am new to PJSIP configurations and asterisk as well. I could configure a sip trunk using sip.conf, but not able to do so using pjsip.conf. Please look at below pjsip.conf at both the servers and tell me where i have gone wrong?

pjsip.conf in asterisk1

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[asterisk2]
type=registration
outbound_auth=asterisk2

[asterisk2]
type=aor
contact=sip:192.168.1.239:5060

[asterisk2]
type=endpoint
context=from-internal
allow=all
outbound_auth=asterisk2
aors=asterisk2

[asterisk2]
type=identify
endpoint=asterisk2
match=192.168.1.239

pjsip.conf in asterisk2

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[asterisk1]
type=registration
outbound_auth=asterisk1

[asterisk1]
type=aor
contact=sip:192.168.0.180:5060

[asterisk1]
type=endpoint
context=from-internal
allow=all
outbound_auth=asterisk1
aors=asterisk1

[asterisk1]
type=identify
endpoint=asterisk1
match=192.168.0.180

You don’t appear to have any authentication sections and your registration section is incomplete (and you aren’t using registration). You can remove the “type=registration” section and the “outbound_auth=” lines to start with and try. If it doesn’t work provide the new configuration and console output, as well as the SIP trace (pjsip set logger on).

just removed

[asterisk1]
type=registration
outbound_auth=asterisk1

from both the servers. Even after pjsip set logger on, i dont see any new requests on console and
localhost*CLI> pjsip show registrations
No objects found.

Please help.

You have to actually place a call in order for traffic to flow. There is no persistent “trunk” or connection.

In extensions.conf of asterisk2

Dial(PJSIP/${CALLERID(num)}@asterisk1)

console output

-- Executing [9005@from-internal:1] NoOp("PJSIP/9001-00000009", ""IVR Application For Sample Audio Check"") in new stack
-- Executing [9005@from-internal:2] NoOp("PJSIP/9001-00000009", "9001") in new stack
-- Executing [9005@from-internal:3] Dial("PJSIP/9001-00000009", "PJSIP/9001@asterisk1") in new stack
-- Called PJSIP/9001@asterisk1

[Mar 14 19:19:34] WARNING[1177]: res_pjsip_sdp_rtp.c:1165 create_outgoing_sdp_stream: Unable to get rtp codec payload code for testlaw
[Mar 14 19:19:34] WARNING[1177]: res_pjsip_sdp_rtp.c:1165 create_outgoing_sdp_stream: Unable to get rtp codec payload code for silk
[Mar 14 19:19:34] WARNING[1177]: res_pjsip_sdp_rtp.c:1165 create_outgoing_sdp_stream: Unable to get rtp codec payload code for silk
[Mar 14 19:19:34] WARNING[1177]: res_pjsip_sdp_rtp.c:1165 create_outgoing_sdp_stream: Unable to get rtp codec payload code for silk
[Mar 14 19:19:34] WARNING[1177]: res_pjsip_sdp_rtp.c:1165 create_outgoing_sdp_stream: Unable to get rtp codec payload code for silk
<— Transmitting SIP request (1911 bytes) to UDP:192.168.0.180:5060 —>
INVITE sip:9001@192.168.0.180:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.239:5060;rport;branch=z9hG4bKPj7ac78658-b2a3-4512-8ebe-6acaa00b4ff6
From: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
To: sip:9001@192.168.0.180
Contact: sip:asterisk@192.168.1.239:5060
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
CSeq: 30693 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 14.2.1
Content-Type: application/sdp
Content-Length: 1256

v=0
o=- 2070095033 2070095033 IN IP4 192.168.1.239
s=Asterisk
c=IN IP4 192.168.1.239
t=0 0
m=audio 11552 RTP/AVP 4 0 8 3 111 112 5 10 122 118 123 124 125 126 127 96 7 18 110 117 119 97 9 102 115 116 107 101
a=rtpmap:4 G723/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:112 AAL2-G726-32/8000
a=rtpmap:5 DVI4/8000
a=rtpmap:10 L16/8000
a=rtpmap:122 L16/12000
a=rtpmap:118 L16/16000
a=rtpmap:123 L16/24000
a=rtpmap:124 L16/32000
a=rtpmap:125 L16/44000
a=rtpmap:126 L16/48000
a=rtpmap:127 L16/96000
a=rtpmap:96 L16/192000
a=rtpmap:7 LPC/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:110 speex/8000
a=rtpmap:117 speex/16000
a=rtpmap:119 speex/32000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=20
a=rtpmap:9 G722/8000
a=rtpmap:102 G7221/16000
a=fmtp:102 bitrate=32000
a=rtpmap:115 G7221/32000
a=fmtp:115 bitrate=48000
a=rtpmap:116 G719/48000
a=rtpmap:107 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv
m=video 13480 RTP/AVP 31 34 98 99 104 100
a=rtpmap:31 H261/90000
a=rtpmap:34 H263/90000
a=rtpmap:98 h263-1998/90000
a=rtpmap:99 H264/90000
a=rtpmap:104 MP4V-ES/90000
a=rtpmap:100 VP8/90000
a=sendrecv

<— Received SIP response (365 bytes) from UDP:192.168.0.180:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.239:5060;rport=5060;received=192.168.1.239;branch=z9hG4bKPj7ac78658-b2a3-4512-8ebe-6acaa00b4ff6
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
From: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
To: sip:9001@192.168.0.180
CSeq: 30693 INVITE
Server: Asterisk PBX 14.2.1
Content-Length: 0

<— Received SIP response (2117 bytes) from UDP:192.168.0.180:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.239:5060;rport=5060;received=192.168.1.239;branch=z9hG4bKPj7ac78658-b2a3-4512-8ebe-6acaa00b4ff6
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
From: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
To: sip:9001@192.168.0.180;tag=02568198-fdb8-45ea-8a55-f17511c4f75c
CSeq: 30693 INVITE
Server: Asterisk PBX 14.2.1
Contact: sip:192.168.0.180:5060
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length: 1434

v=0
o=- 2070095033 2070095035 IN IP4 192.168.0.180
s=Asterisk
c=IN IP4 192.168.0.180
t=0 0
m=audio 13150 RTP/AVP 4 0 8 3 111 112 5 10 122 118 123 124 125 126 127 96 7 18 110 117 119 97 9 102 115 116 107 101
a=rtpmap:4 G723/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:112 AAL2-G726-32/8000
a=rtpmap:5 DVI4/8000
a=rtpmap:10 L16/8000
a=rtpmap:122 L16/12000
a=rtpmap:118 L16/16000
a=rtpmap:123 L16/24000
a=rtpmap:124 L16/32000
a=rtpmap:125 L16/44000
a=rtpmap:126 L16/48000
a=rtpmap:127 L16/96000
a=rtpmap:96 L16/192000
a=rtpmap:7 LPC/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:110 speex/8000
a=rtpmap:117 speex/16000
a=rtpmap:119 speex/32000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=20
a=rtpmap:9 G722/8000
a=rtpmap:102 G7221/16000
a=fmtp:102 bitrate=32000
a=rtpmap:115 G7221/32000
a=fmtp:115 bitrate=48000
a=rtpmap:116 G719/48000
a=rtpmap:107 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv
m=video 11352 RTP/AVP 31 34 98 99 104 100
a=rtpmap:31 H261/90000
a=rtpmap:34 H263/90000
a=fmtp:34 SQCIF=0;QCIF=0;CIF=0;CIF4=0;CIF16=0;VGA=0;F=0;I=0;J=0;T=0;K=0;N=0;BPP=0;HRD=0
a=rtpmap:98 h263-1998/90000
a=fmtp:98 SQCIF=0;QCIF=0;CIF=0;CIF4=0;CIF16=0;VGA=0;F=0;I=0;J=0;T=0;K=0;N=0;BPP=0;HRD=0
a=rtpmap:99 H264/90000
a=rtpmap:104 MP4V-ES/90000
a=rtpmap:100 VP8/90000
a=sendrecv

<— Transmitting SIP request (413 bytes) to UDP:192.168.0.180:5060 —>
ACK sip:192.168.0.180:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.239:5060;rport;branch=z9hG4bKPje5e5377c-0a00-469f-b3fa-2e4d51319dc3
From: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
To: sip:9001@192.168.0.180;tag=02568198-fdb8-45ea-8a55-f17511c4f75c
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
CSeq: 30693 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 14.2.1
Content-Length: 0

-- PJSIP/asterisk1-0000000a answered PJSIP/9001-00000009

<— Transmitting SIP response (832 bytes) to UDP:192.168.2.219:55103 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.2.219:55103;rport=55103;received=192.168.2.219;branch=z9hG4bK-524287-1—0df79b4a5e341460
Call-ID: 83372NTEwNGM5ZGI3N2FhNWY1MzM3ZDAwNGQxMzllYzFiNmY
From: sip:9001@192.168.1.239;tag=0c25dd6d
To: sip:9005@192.168.1.239;tag=bc6cfa02-3c09-4f98-8216-b15a44e2cbed
CSeq: 2 INVITE
Server: Asterisk PBX 14.2.1
Contact: sip:192.168.1.239:5060
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length: 230

v=0
o=- 1405370297 3 IN IP4 192.168.1.239
s=Asterisk
c=IN IP4 192.168.1.239
t=0 0
m=audio 18690 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

-- Channel PJSIP/asterisk1-0000000a joined 'simple_bridge' basic-bridge <5c567689-5eda-425e-aa38-f3ed11c960f2>
-- Channel PJSIP/9001-00000009 joined 'simple_bridge' basic-bridge <5c567689-5eda-425e-aa38-f3ed11c960f2>

<— Received SIP request (466 bytes) from UDP:192.168.2.219:55103 —>
ACK sip:192.168.1.239:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.219:55103;branch=z9hG4bK-524287-1—9dbbc96e3e2cce45;rport
Max-Forwards: 70
Contact: sip:9001@192.168.2.219:55103;rinstance=7be1afaddac30a58
To: sip:9005@192.168.1.239;tag=bc6cfa02-3c09-4f98-8216-b15a44e2cbed
From: sip:9001@192.168.1.239;tag=0c25dd6d
Call-ID: 83372NTEwNGM5ZGI3N2FhNWY1MzM3ZDAwNGQxMzllYzFiNmY
CSeq: 2 ACK
User-Agent: X-Lite release 4.9.7.1 stamp 83372
Content-Length: 0

   > 0x7f437400fdb0 -- Probation passed - setting RTP source address to 192.168.2.219:52182

<— Received SIP request (445 bytes) from UDP:192.168.0.180:5060 —>
BYE sip:asterisk@192.168.1.239:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.180:5060;rport;branch=z9hG4bKPj5a9c6a0e-5110-4fe4-a769-fe87c460e32d
From: sip:9001@192.168.0.180;tag=02568198-fdb8-45ea-8a55-f17511c4f75c
To: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
CSeq: 6794 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 14.2.1
Content-Length: 0

<— Transmitting SIP response (398 bytes) to UDP:192.168.0.180:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.180:5060;rport=5060;received=192.168.0.180;branch=z9hG4bKPj5a9c6a0e-5110-4fe4-a769-fe87c460e32d
Call-ID: c0fb6e8c-f82b-4c99-8ba5-5c22ad19d6cf
From: sip:9001@192.168.0.180;tag=02568198-fdb8-45ea-8a55-f17511c4f75c
To: sip:9001@192.168.1.239;tag=83b487c5-5990-4beb-8ded-1be61d821043
CSeq: 6794 BYE
Server: Asterisk PBX 14.2.1
Content-Length: 0

-- Channel PJSIP/asterisk1-0000000a left 'simple_bridge' basic-bridge <5c567689-5eda-425e-aa38-f3ed11c960f2>
-- Channel PJSIP/9001-00000009 left 'simple_bridge' basic-bridge <5c567689-5eda-425e-aa38-f3ed11c960f2>

== Spawn extension (from-internal, 9005, 3) exited non-zero on ‘PJSIP/9001-00000009’
<— Transmitting SIP request (454 bytes) to UDP:192.168.2.219:55103 —>
BYE sip:9001@192.168.2.219:55103;rinstance=7be1afaddac30a58 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.239:5060;rport;branch=z9hG4bKPjda6e240e-955b-4a94-8a2f-fcab126c3269
From: sip:9005@192.168.1.239;tag=bc6cfa02-3c09-4f98-8216-b15a44e2cbed
To: sip:9001@192.168.1.239;tag=0c25dd6d
Call-ID: 83372NTEwNGM5ZGI3N2FhNWY1MzM3ZDAwNGQxMzllYzFiNmY
CSeq: 25655 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 14.2.1
Content-Length: 0

<— Received SIP response (446 bytes) from UDP:192.168.2.219:55103 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.239:5060;rport=5060;branch=z9hG4bKPjda6e240e-955b-4a94-8a2f-fcab126c3269
Contact: sip:9001@192.168.2.219:55103;rinstance=7be1afaddac30a58
To: sip:9001@192.168.1.239;tag=0c25dd6d
From: sip:9005@192.168.1.239;tag=bc6cfa02-3c09-4f98-8216-b15a44e2cbed
Call-ID: 83372NTEwNGM5ZGI3N2FhNWY1MzM3ZDAwNGQxMzllYzFiNmY
CSeq: 25655 BYE
User-Agent: X-Lite release 4.9.7.1 stamp 83372
Content-Length: 0

Does this mean that the trunk is established?

It means that a call was established fine and then was hung up. The configuration seems to work.

Yay, thanks for your prompt response.