PJSIP no outbound calls possible

Good morning (o;

As I had to migrate away an old Debian server I had to compile Asterisk from sources with bundled pjsip.

Took some time for me to configure pjsip.conf so that inbound calls are possible again…
but just no outbound calls are possible…console is stuck at saying:

Called PJSIP/078XXXXXXX@mytrunk

Oddly I see in the pjsip logs that it tries to call my own server instead if I interpret that correctly:

SIP/2.0 100 Trying
Via: SIP/2.0/UDP 217xx.yy.221:56883;rport=5061;received=217.xx.yy.221;branch=z9hG4bK11666218
Call-ID: 536921510-5061-23@CBH.CC.BCI.CCB
From: "Richard Klingler" <sip:999@sip.example.ch>;tag=821746638
To: <sip:078XXXXXXX@sip.example.ch>
CSeq: 221 INVITE
Server: Asterisk PBX 21.2.0

My trunk is configured as:

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

[mytrunk]
type=registration
transport=simpletrans
outbound_auth= mytrunk
server_uri=sip:sip.mytrunk.ch
client_uri=sip:username@sip.mytrunk.ch
retry_interval=60
support_outbound=yes

[mytrunk]
type=auth
auth_type=userpass
password=password
username=username

[mytrunk]
type=aor
contact=sip:username@sip.mytrunk.ch:5060

[mytrunk]
type=endpoint
context=incoming
direct_media=no
allow=!all,g722,ulaw
outbound_auth= mytrunk
outbound_proxy=sip.mytrunk.ch:5060
aors=efon
force_rport=no
rtp_symmetric=yes

[mytrunk]
type=identify
endpoint= mytrunk
match=sip.mytrunk.ch

I’m totally lost here and would appreciate any pointers (o;

  1. Is your pjsip endpoint showing as “not in use” when you do “pjsip show endpoints”?
  2. Is your registration showing as registered when you do “pjsip show registrations”?
  3. Can you share more logs from Asterisk console after setting “pjsip set logger on” or “pjsip set history on” and then running “pjsip show history” after attempting a call.

As you can see a 100 Trying message my bet is you are getting this response from the provider and there is some thing wrong up stream. So there should be some message coming after that.

This what pjsip show endpoints tells me:

Endpoint:  999/061xxxxxx9                                       Not in use    0 of inf
     InAuth:  auth999/999
        Aor:  999                                                1
      Contact:  999/sip:999@217xx.yy.221:5061            e5bfb8c1a8 NonQual         nan

 Endpoint:  mytrunk                                                 Not in use    0 of inf
    OutAuth:  mytrunk/061xxxxxx5
        Aor:  mytrunk                                               0
      Contact:  mytrunk/sip:sip.mytrunk.ch:5060               21687a2abb NonQual         nan
   Identify:  mytrunk/mytrunk
        Match: 212.xx.yy.132/32
        Match: 77.xx.yy.155/32

Asterisk is registered to my provder:

mail*CLI> pjsip show registrations

 <Registration/ServerURI..............................>  <Auth....................>  <Status.......>
==========================================================================================

 efon/sip:sip.mytrunk.ch                                 efon                        Registered        (exp. 2273s)

And this shows the pjsip logger when dialing a number:

<--- Received SIP request (1304 bytes) from UDP:217.xx.yy.221:5061 --->
INVITE sip:078xxxxxxx@sip.myasterisk.ch SIP/2.0
Via: SIP/2.0/UDP 217.xx.yy.221:32907;branch=z9hG4bK992722553;rport
From: "Richard Klingler" <sip:999@sip.myasterisk.ch>;tag=762898078
To: <sip:078xxxxxxx@sip.myasterisk.ch>
Call-ID: 2015672201-5061-37@CBH.CC.BCI.CCB
CSeq: 360 INVITE
Contact: "Richard Klingler" <sip:999@217.xx.yy.221:5061>
X-Grandstream-PBX: true
Max-Forwards: 70
User-Agent: Grandstream GXP2160 1.0.11.64
Privacy: none
P-Preferred-Identity: "Richard Klingler" <sip:999@sip.myasterisk.ch>
P-Access-Network-Info: IEEE-EUI-48;eui-48-addr=04-B4-FE-86-91-D9
P-Emergency-Info: IEEE-EUI-48;eui-48-addr=00-0B-82-F8-EB-B3
Supported: replaces, path, timer
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Accept: application/sdp, application/dtmf-relay
Content-Length:   437

v=0
o=999 8000 8000 IN IP4 217.xx.yy.221
s=SIP Call
c=IN IP4 217.xx.yy.221
t=0 0
m=audio 10710 RTP/AVP 0 8 4 18 9 97 2 123 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:9 G722/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:2 G726-32/8000
a=rtpmap:123 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

<--- Transmitting SIP response (508 bytes) to UDP:217.xx.yy.221:5061 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 217.xx.yy.221:32907;rport=5061;received=217.xx.yy.221;branch=z9hG4bK992722553
Call-ID: 2015672201-5061-37@CBH.CC.BCI.CCB
From: "Richard Klingler" <sip:999@sip.myasterisk.ch>;tag=762898078
To: <sip:078xxxxxxx@sip.myasterisk.ch>;tag=z9hG4bK992722553
CSeq: 360 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1714036503/08de41e1df2ab5c899b9e7fa55dd4fdb",opaque="7a15431d7b41ea81",algorithm=MD5,qop="auth"
Server: Asterisk PBX 21.2.0
Content-Length:  0


<--- Received SIP request (318 bytes) from UDP:217.xx.yy.221:5061 --->
ACK sip:078xxxxxxx@sip.myasterisk.ch SIP/2.0
Via: SIP/2.0/UDP 217.xx.yy.221:32907;branch=z9hG4bK992722553;rport
From: "Richard Klingler" <sip:999@sip.myasterisk.ch>;tag=762898078
To: <sip:078xxxxxxx@sip.myasterisk.ch>;tag=z9hG4bK992722553
Call-ID: 2015672201-5061-37@CBH.CC.BCI.CCB
CSeq: 360 ACK
Content-Length: 0


<--- Received SIP request (1580 bytes) from UDP:217.xx.yy.221:5061 --->
INVITE sip:078xxxxxxx@sip.myasterisk.ch SIP/2.0
Via: SIP/2.0/UDP 217.xx.yy.221:32907;branch=z9hG4bK472423144;rport
From: "Richard Klingler" <sip:999@sip.myasterisk.ch>;tag=762898078
To: <sip:078xxxxxxx@sip.myasterisk.ch>
Call-ID: 2015672201-5061-37@CBH.CC.BCI.CCB
CSeq: 361 INVITE
Contact: "Richard Klingler" <sip:999@217.xx.yy.221:5061>
Authorization: Digest username="999", realm="asterisk", nonce="1714036503/08de41e1df2ab5c899b9e7fa55dd4fdb", uri="sip:078xxxxxxx@sip.myasterisk.ch", response="905ece8c6b4c892546d4e6a77a7a6ea9", algorithm=MD5, cnonce="00369037", opaque="7a15431d7b41ea81", qop=auth, nc=00000001
X-Grandstream-PBX: true
Max-Forwards: 70
User-Agent: Grandstream GXP2160 1.0.11.64
Privacy: none
P-Preferred-Identity: "Richard Klingler" <sip:999@sip.myasterisk.ch>
P-Access-Network-Info: IEEE-EUI-48;eui-48-addr=04-B4-FE-86-91-D9
P-Emergency-Info: IEEE-EUI-48;eui-48-addr=00-0B-82-F8-EB-B3
Supported: replaces, path, timer
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Accept: application/sdp, application/dtmf-relay
Content-Length:   437

v=0
o=999 8000 8000 IN IP4 217.xx.yy.221
s=SIP Call
c=IN IP4 217.xx.yy.221
t=0 0
m=audio 10710 RTP/AVP 0 8 4 18 9 97 2 123 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:9 G722/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:2 G726-32/8000
a=rtpmap:123 opus/48000/2
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

<--- Transmitting SIP response (335 bytes) to UDP:217.xx.yy.221:5061 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 217.xx.yy.221:32907;rport=5061;received=217.xx.yy.221;branch=z9hG4bK472423144
Call-ID: 2015672201-5061-37@CBH.CC.BCI.CCB
From: "Richard Klingler" <sip:999@sip.myasterisk.ch>;tag=762898078
To: <sip:078xxxxxxx@sip.myasterisk.ch>
CSeq: 361 INVITE
Server: Asterisk PBX 21.2.0
Content-Length:  0


    -- Executing [078xxxxxxx@from-klingler:1] Verbose("PJSIP/999-0000000c", "1, "Calling, 078xxxxxxx") in new stack
  "Calling, 078xxxxxxx
    -- Executing [078xxxxxxx@from-klingler:2] Dial("PJSIP/999-0000000c", "PJSIP/078xxxxxxx@efon") in new stack
    -- Called PJSIP/078xxxxxxx@efon

Somehow my provers server isn’t involved at all…
Also seem not to accept the P-Preferred-Identity as set in the dial plan:

exten => _0[1-8]XXXXXXXX,1,Set(PJSIP_HEADER(add,P-Preferred-Identity=<sip:${CALLERID(num)}@e-fon.ch>)

This AOR is not included in the configuration you provided, but would be the source of the problem.

Without the IP level information this doesn’t tell you very much except in as much as the request URI and To header would have started out the same.

The port numbers in the Via are all over the place. It claims the call originator used a non-standard port number in the Via, but the call was actually received from a different non-standard port number (the SIPS one, not the SIP one). I think you may have a rogue router with SIP ALG turned on.

Also note that Trying can come from a proxy so even the source IP address doesn’t say to whom you sent the INVITE. You need the INVITE, ideally with IP and UDP level information.

I just forgot to rename this aor to mytrunk (o;

Just wondering why the same setup with my IP phones worked flawlessly before with an older asterisk and chan_sip and now with pjsip it is a pain in the a** to get it working…

Same IP phones, same Fritbox routers, same network configuration.

Tried the python conversion script for sip.conf…but this produces a non usable pjsip.conf.

How would that old trunk snipper from sip.conf translate correctly to pjsip?

[mytrunk]
type=peer
username=061xxxxxxx
secret=password
host=212.xx.yy.132
context=incoming
qualify=2000
fromuser=061xxxxxxx
fromdomain=myprover.ch
sendrpid=yes
canreinvite=no
insecure=invite

This doesn’t translate as it does nothing when host isn’t dynamic.

Your original log snippet appears to apply to endpoint 999, but you did not provide the PJSIP configuration for that.

Your new log snippet also only includes the call from 999. It stops just before you would expect an INVITE to efon to be seen.

PJSIP_HEADER needs to be run on the B side, but you have no pre-dial handler in your Dial() call.

Also the log shows that it is not being run on the A side, at all.

This isn’t in the sip.conf, and one normally need \;lr at the end, and, possibly, \;hide

sendrpid hasn’t been translated, but you wouldn’t normally want it if they insist on p-preferred-id for caller ID.

The sip.conf only supports one source address, from the provider end.

As nat= is default in sip.conf, both force_rport and rtp_symmetric would have the same value, which, I think, would be no, in this case.

from_user and from_domain have not been translated from the sip.conf.