Asterisk through a VPN is not working

Hello everyone,

I am new to Asterisk and I have set it up on a VM to experiment it.

I set up 2 PJSIP extensions, 1067 and 1092. I opened my port 5060. It works perfectly in my local network, and with a friend’s network (microSIP).
But, if I try to make a call through a VPN (NordVPN or a private VPN), it doesn’t work. I can log in but I can’t make any call.
There is no log in the Asterisk’s console when I make a call.

There are my config files :

my pjsip.conf -------------

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

#include users/1067.conf
#include users/1092.conf

my 1067/1092.conf (they are both the same) -------------

[1067]

type=auth
auth_type=userpass
password=XXXXXXX
username=1067

[1067]

type=endpoint
transport=transport-udp
auth=1067
aors=1067
context=Tout
disallow=all
allow=opus
allow=ulaw
allow=alaw
call_group=1
pickup_group=1
direct_media=no
callerid=0033123456789

[1067]

type=aor
max_contacts=10

Did I miss something in my configuration ?
Sorry, I am very new to Asterisk.

Thanks a lot :slight_smile:

NordVPN is an anonymising service that makes use of VPN technology, not a VPN. In particular, it will do address translation, and you won’t know the real public address. Very aggressive use of STUN may get it to work but I don’t think that you would be working within the specification, so it could break at any time.

You use private VPN in the same parentheses as NordVPN, so I’m not convinced you are using the private one in a normal way.

Note that 1067 and 1092 are endpoints, not extensions. Using extensions for them is FreePBX terminology.

It can only work on private vpn and you will need to setup asterisk and the phones to use the private addresses that are used by the vpn.

Thanks for your answers.
Yes I was working with FreePBX before, I was confused with the terms, sorry.
Yes I have NordVPN to mask my IP but if it’s not working, no problem, I was just worried about a bad network configuration or something like that.
Will experiment if it’s working with others networks before installing it on a VPS.

Hey again,
I tested with my smartphone and via Wifi it’s working perfectly, but when I switch to 4G it doesn’t work again, so that’s not a VPN issue.

There is the log when 1092 calls 1067 via 4G :

   -- Executing [1067@Tout:1] Dial("PJSIP/1092-00000014", "PJSIP/1067,20") in new stack
    -- Called PJSIP/1067
    -- PJSIP/1067-00000015 is ringing
       > 0x7f4cf00da6a0 -- Strict RTP learning after remote address set to: 192.168.1.254:4020
    -- PJSIP/1067-00000015 answered PJSIP/1092-00000014
       > 0x7f4cf000b2e0 -- Strict RTP learning after remote address set to: 10.25.222.34:4012
    -- Channel PJSIP/1067-00000015 joined 'simple_bridge' basic-bridge <fea2f899-e432-4fd6-ab90-3b043da078fb>
    -- Channel PJSIP/1092-00000014 joined 'simple_bridge' basic-bridge <fea2f899-e432-4fd6-ab90-3b043da078fb>
       > Bridge fea2f899-e432-4fd6-ab90-3b043da078fb: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1092-00000014' and 'PJSIP/1067-00000015' in stack
       > 0x7f4cf00da6a0 -- Strict RTP switching to RTP target address 192.168.1.254:4020 as source
[Aug  7 15:09:12] WARNING[1038][C-0000000b]: res_rtp_asterisk.c:7695 ast_rtp_read: RTP Read too short
       > 0x7f4cf000b2e0 -- Strict RTP qualifying stream type: audio
       > 0x7f4cf000b2e0 -- Strict RTP switching source address to 37.164.85.82:60534
       > 0x7f4cf00da6a0 -- Strict RTP learning complete - Locking on source address 192.168.1.254:4020
       > 0x7f4cf000b2e0 -- Strict RTP learning complete - Locking on source address 37.164.85.82:60534

Does anyone have an idea ?
Thanks a lot

The log doesn’t seems to show a successful call.

Which log can be useful to see what happened ?

You may need to obtain several logs.

What is the precise failure you are seeing? If it is no audio, you should turn on RTP debugging and confirm that packets are being sent and received on both sides. That should help show where they are getting lost.

The pjsip set logger on output is also going to be helpful, in showing which addresses are being sent.

I notice you have a mixture of public and private addresses. Could you please describe your network topology, and confirm that the Asterisk machine has a direct connection to the public network?

With Wifi it works perfectly.
With 4G :

  • There is no audio on 1092 but there is audio on 1067
  • I can put the call on hold from 1092.
  • I can reach 1067 from 1092 but not 1092 from 1067.

There are RTP logs :

RTP Packet Debugging Enabled
    -- Executing [1067@Tout:1] Dial("PJSIP/1092-0000000d", "PJSIP/1067,20") in new stack
    -- Called PJSIP/1067
    -- PJSIP/1067-0000000e is ringing
       > 0x558c7bad6fb0 -- Strict RTP learning after remote address set to: 192.168.1.254:4012
    -- PJSIP/1067-0000000e answered PJSIP/1092-0000000d
       > 0x7f92f001d3c0 -- Strict RTP learning after remote address set to: 10.25.222.34:4002
    -- Channel PJSIP/1067-0000000e joined 'simple_bridge' basic-bridge <9f579a4f-5520-43b2-99a4-a35fff66206b>
    -- Channel PJSIP/1092-0000000d joined 'simple_bridge' basic-bridge <9f579a4f-5520-43b2-99a4-a35fff66206b>
       > Bridge 9f579a4f-5520-43b2-99a4-a35fff66206b: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1092-0000000d' and 'PJSIP/1067-0000000e' in stack
       > 0x558c7bad6fb0 -- Strict RTP switching to RTP target address 192.168.1.254:4012 as source
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024439, ts 000960, len 000052)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000052)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024440, ts 001920, len 000057)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000057)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024441, ts 002880, len 000058)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000058)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024442, ts 003840, len 000065)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000065)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024443, ts 004800, len 000088)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000088)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024444, ts 005760, len 000065)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000065)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024445, ts 006720, len 000063)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000063)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024446, ts 007680, len 000056)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000056)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024447, ts 008640, len 000054)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000054)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024448, ts 009600, len 000058)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000058)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024449, ts 010560, len 000054)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000054)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024450, ts 011520, len 000056)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000056)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024451, ts 012480, len 000088)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000088)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024452, ts 013440, len 000061)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000061)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024453, ts 014400, len 000059)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000059)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024454, ts 015360, len 000056)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000056)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024455, ts 016320, len 000058)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000058)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024456, ts 017280, len 000056)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000056)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024457, ts 018240, len 000054)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000054)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024458, ts 019200, len 000060)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000060)
Got  RTP packet from    192.168.1.254:4012 (type 107, seq 024459, ts 020160, len 000055)
Sent RTP P2P packet to 10.25.222.34:4002 (type 120, len 000055)

I’m not an expert but I guess that Asterisk is trying to work with the local IP, not the public.
Is this okay?

You are not receiving any media from 10.25.222.34. What IP address are you including in the SDP sent to that. Which of the 10.* and 192.* sub-networks, respectively, correspond to 1092 and 1067. What is Asterisk’s address? I guess 1067 is the 10.* one.

Does Asterisk abort the call to 1067 after about 30 seconds?

pjsip set logger on for a call from 1067 to 1092 would be useful.

Only if the local IP is route-able.

Note you have not made any provision for Asterisk to discover a public address, unless it is directly on one of the machine’s interfaces.

Okay, so I set up some things to “force” Asterisk to work with NAT.

My new 1067/1092.conf :

[1092]

type=auth
auth_type=userpass
password=XXXXXX
username=1092

[1092]

type=endpoint
transport=transport-udp
auth=1092
aors=1092
context=Tout
disallow=all
allow=opus
allow=ulaw
allow=alaw
call_group=1
pickup_group=1
rewrite_contact = yes
direct_media = no 
force_rport = yes
rtp_symmetric = yes
callerid=0033695614177

[1092]

type=aor
max_contacts=10

My new pjsip.conf :

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
local_net = 192.168.1.0/24
external_media_address = my_external_ip
external_signaling_address = my_external_ip

#include users/1067.conf
#include users/1092.conf

Now I don’t have audio on both ways.
I made a call from 1067 to 1092, and there are the logs (i just replaced my external ip with MY_EXTERNAL_IP :


PJSIP Logging enabled
<--- Received SIP request (1170 bytes) from UDP:192.168.1.254:59617 --->
INVITE sip:1092@192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPjf275fa1de39d4a0085b5684a1e57b0fb
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>
Contact: <sip:1067@192.168.1.254:59617;ob>
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11679 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.20.5
Content-Type: application/sdp
Content-Length:   536

v=0
o=- 3837352437 3837352437 IN IP4 192.168.1.254
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4004 RTP/AVP 8 0 96 101 102
c=IN IP4 192.168.1.254
b=TIAS:64000
a=rtcp:4005 IN IP4 192.168.1.50
a=sendrecv
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:96 opus/48000/2
a=fmtp:96 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1;stereo=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:102 telephone-event/48000
a=fmtp:102 0-16
a=ssrc:1991718844 cname:158843e20b87506a

<--- Transmitting SIP response (552 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPjf275fa1de39d4a0085b5684a1e57b0fb
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>;tag=z9hG4bKPjf275fa1de39d4a0085b5684a1e57b0fb
CSeq: 11679 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1628356437/5af2a600ff2f4e402bb1a271385e71d7",opaque="0f769a32699af15d",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.19.1
Content-Length:  0


<--- Received SIP request (386 bytes) from UDP:192.168.1.254:59617 --->
ACK sip:1092@192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPjf275fa1de39d4a0085b5684a1e57b0fb
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>;tag=z9hG4bKPjf275fa1de39d4a0085b5684a1e57b0fb
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11679 ACK
Content-Length:  0


<--- Received SIP request (1463 bytes) from UDP:192.168.1.254:59617 --->
INVITE sip:1092@192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPj9bf4b92096a2413d8c056be5872b6ee4
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>
Contact: <sip:1067@192.168.1.254:59617;ob>
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11680 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.20.5
Authorization: Digest username="1067", realm="asterisk", nonce="1628356437/5af2a600ff2f4e402bb1a271385e71d7", uri="sip:1092@MY_EXTERNAL_IP", response="cd32d89a219a2a53c85cd5ab011a2ec8", algorithm=md5, cnonce="fce690cc903a47e1a47c3662d328941e", opaque="0f769a32699af15d", qop=auth, nc=00000001
Content-Type: application/sdp
Content-Length:   536

v=0
o=- 3837352437 3837352437 IN IP4 192.168.1.254
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4004 RTP/AVP 8 0 96 101 102
c=IN IP4 192.168.1.254
b=TIAS:64000
a=rtcp:4005 IN IP4 192.168.1.50
a=sendrecv
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:96 opus/48000/2
a=fmtp:96 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1;stereo=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:102 telephone-event/48000
a=fmtp:102 0-16
a=ssrc:1991718844 cname:158843e20b87506a

<--- Transmitting SIP response (354 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPj9bf4b92096a2413d8c056be5872b6ee4
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>
CSeq: 11680 INVITE
Server: Asterisk PBX 16.19.1
Content-Length:  0


    -- Executing [1092@Tout:1] Dial("PJSIP/1067-00000002", "PJSIP/1092,20") in new stack
    -- Called PJSIP/1092
<--- Transmitting SIP request (1117 bytes) to UDP:37.165.21.89:46620 --->
INVITE sip:1092@37.165.21.89:46620;rinstance=7ec5b67d640140bd SIP/2.0
Via: SIP/2.0/UDP MY_EXTERNAL_IP:5060;rport;branch=z9hG4bKPjec4fab85-8255-41e2-a2f2-ca0462625f51
From: <sip:0033695614152@192.168.1.80>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>
Contact: <sip:asterisk@MY_EXTERNAL_IP:5060>
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1050 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 16.19.1
Content-Type: application/sdp
Content-Length:   391

v=0
o=- 725471504 725471504 IN IP4 MY_EXTERNAL_IP
s=Asterisk
c=IN IP4 MY_EXTERNAL_IP
t=0 0
m=audio 16314 RTP/AVP 107 0 8 101
a=rtpmap:107 opus/48000/2
a=fmtp:107 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

<--- Received SIP response (432 bytes) from UDP:37.165.21.89:46620 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.80:5060;rport=5060;branch=z9hG4bKPjec4fab85-8255-41e2-a2f2-ca0462625f51
Contact: <sip:1092@10.45.220.57:44658>
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
From: <sip:0033695614152@192.168.1.80:5060>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1050 INVITE
User-Agent: SessionTalk 6.0
Content-Length: 0


    -- PJSIP/1092-00000003 is ringing
<--- Transmitting SIP response (541 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPj9bf4b92096a2413d8c056be5872b6ee4
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>;tag=a9380a24-8b30-454e-a658-1039137f3b22
CSeq: 11680 INVITE
Server: Asterisk PBX 16.19.1
Contact: <sip:192.168.1.80:5060>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Content-Length:  0


<--- Received SIP response (432 bytes) from UDP:37.165.21.89:46620 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.80:5060;rport=5060;branch=z9hG4bKPjec4fab85-8255-41e2-a2f2-ca0462625f51
Contact: <sip:1092@10.45.220.57:44658>
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
From: <sip:0033695614152@192.168.1.80:5060>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1050 INVITE
User-Agent: SessionTalk 6.0
Content-Length: 0


    -- PJSIP/1092-00000003 is ringing
<--- Received SIP response (914 bytes) from UDP:37.165.21.89:46620 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.80:5060;rport=5060;branch=z9hG4bKPjec4fab85-8255-41e2-a2f2-ca0462625f51
Require: timer
Contact: <sip:1092@10.45.220.57:44658>
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
From: <sip:0033695614152@192.168.1.80:5060>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1050 INVITE
Session-Expires: 1800;refresher=uac
Min-SE: 90
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, SUBSCRIBE, UPDATE, INFO, MESSAGE
Content-Type: application/sdp
Supported: path, replaces, timer, norefersub
User-Agent: SessionTalk 6.0
Content-Length: 252

v=0
o=- 0 1 IN IP4 10.45.220.57
s=-
c=IN IP4 10.45.220.57
t=0 0
m=audio 4002 RTP/AVP 107 101
a=rtpmap:107 opus/48000/2
a=fmtp:107 useinbandfec=1; usedtx=1; maxaveragebitrate=64000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv

       > 0x7fce44004f10 -- Strict RTP learning after remote address set to: 10.45.220.57:4002
<--- Transmitting SIP request (424 bytes) to UDP:37.165.21.89:46620 --->
ACK sip:1092@37.165.21.89:46620 SIP/2.0
Via: SIP/2.0/UDP MY_EXTERNAL_IP:5060;rport;branch=z9hG4bKPj4778b7a8-e9e4-4bf0-aca6-e9c7f4c81de4
From: <sip:0033695614152@192.168.1.80>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1050 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 16.19.1
Content-Length:  0


    -- PJSIP/1092-00000003 answered PJSIP/1067-00000002
       > 0x7fce60012400 -- Strict RTP learning after remote address set to: 192.168.1.254:4004
<--- Transmitting SIP response (1059 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPj9bf4b92096a2413d8c056be5872b6ee4
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>;tag=a9380a24-8b30-454e-a658-1039137f3b22
CSeq: 11680 INVITE
Server: Asterisk PBX 16.19.1
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Contact: <sip:192.168.1.80:5060>
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length:   388

v=0
o=- 3837352437 3837352439 IN IP4 192.168.1.80
s=Asterisk
c=IN IP4 192.168.1.80
t=0 0
m=audio 17532 RTP/AVP 96 0 8 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

    -- Channel PJSIP/1092-00000003 joined 'simple_bridge' basic-bridge <e2df4bb7-2f24-4993-8fae-e80f75f6d580>
    -- Channel PJSIP/1067-00000002 joined 'simple_bridge' basic-bridge <e2df4bb7-2f24-4993-8fae-e80f75f6d580>
       > Bridge e2df4bb7-2f24-4993-8fae-e80f75f6d580: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1067-00000002' and 'PJSIP/1092-00000003' in stack
<--- Received SIP request (376 bytes) from UDP:192.168.1.254:59617 --->
ACK sip:192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPj3bb93443b31d448ca88645cd1753fc0c
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>;tag=a9380a24-8b30-454e-a658-1039137f3b22
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11680 ACK
Content-Length:  0


<--- Received SIP request (988 bytes) from UDP:192.168.1.254:59617 --->
UPDATE sip:192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPjecbfd1ab80fd43c0a13082ab88ff3b5f
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>;tag=a9380a24-8b30-454e-a658-1039137f3b22
Contact: <sip:1067@192.168.1.254:59617;ob>
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11681 UPDATE
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800;refresher=uac
Min-SE: 90
Content-Type: application/sdp
Content-Length:   431

v=0
o=- 3837352437 3837352438 IN IP4 192.168.1.254
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4004 RTP/AVP 96 101
c=IN IP4 192.168.1.254
b=TIAS:64000
a=rtcp:4005 IN IP4 192.168.1.50
a=ssrc:1991718844 cname:158843e20b87506a
a=rtpmap:96 opus/48000/2
a=fmtp:96 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1;stereo=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv

       > 0x7fce60012400 -- Strict RTP learning after remote address set to: 192.168.1.254:4004
<--- Transmitting SIP response (1011 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPjecbfd1ab80fd43c0a13082ab88ff3b5f
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>;tag=a9380a24-8b30-454e-a658-1039137f3b22
CSeq: 11681 UPDATE
Session-Expires: 1800;refresher=uac
Require: timer
Contact: <sip:192.168.1.80:5060>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Server: Asterisk PBX 16.19.1
Content-Type: application/sdp
Content-Length:   340

v=0
o=- 3837352437 3837352440 IN IP4 192.168.1.80
s=Asterisk
c=IN IP4 192.168.1.80
t=0 0
m=audio 17532 RTP/AVP 96 101
a=rtpmap:96 opus/48000/2
a=fmtp:96 maxplaybackrate=24000;sprop-maxcapturerate=24000;maxaveragebitrate=64000;useinbandfec=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

       > Locally RTP bridged 'PJSIP/1067-00000002' and 'PJSIP/1092-00000003' in stack
       > 0x7fce60012400 -- Strict RTP switching to RTP target address 192.168.1.254:4004 as source
       > 0x7fce60012400 -- Strict RTP learning complete - Locking on source address 192.168.1.254:4004
<--- Received SIP request (405 bytes) from UDP:192.168.1.254:59617 --->
BYE sip:192.168.1.80:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.254:59617;rport;branch=z9hG4bKPj5d05b0cc49484433bfc9a69768265e8f
Max-Forwards: 70
From: <sip:1067@192.168.1.80:5060>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80:5060>;tag=a9380a24-8b30-454e-a658-1039137f3b22
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
CSeq: 11682 BYE
User-Agent: MicroSIP/3.20.5
Content-Length:  0


<--- Transmitting SIP response (388 bytes) to UDP:192.168.1.254:59617 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.254:59617;rport=59617;received=192.168.1.254;branch=z9hG4bKPj5d05b0cc49484433bfc9a69768265e8f
Call-ID: 4094f09e0cfc4f56a80cf0f26f25a2d4
From: <sip:1067@192.168.1.80>;tag=7148a006d7344a8c867f7a9f336afb9c
To: <sip:1092@192.168.1.80>;tag=a9380a24-8b30-454e-a658-1039137f3b22
CSeq: 11682 BYE
Server: Asterisk PBX 16.19.1
Content-Length:  0


    -- Channel PJSIP/1067-00000002 left 'native_rtp' basic-bridge <e2df4bb7-2f24-4993-8fae-e80f75f6d580>
    -- Channel PJSIP/1092-00000003 left 'native_rtp' basic-bridge <e2df4bb7-2f24-4993-8fae-e80f75f6d580>
  == Spawn extension (Tout, 1092, 1) exited non-zero on 'PJSIP/1067-00000002'
<--- Transmitting SIP request (448 bytes) to UDP:37.165.21.89:46620 --->
BYE sip:1092@37.165.21.89:46620 SIP/2.0
Via: SIP/2.0/UDP MY_EXTERNAL_IP:5060;rport;branch=z9hG4bKPj266e06c4-f8c1-407e-b496-5b72fca001e1
From: <sip:0033695614152@192.168.1.80>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1051 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 16.19.1
Content-Length:  0


<--- Received SIP response (424 bytes) from UDP:37.165.21.89:46620 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.80:5060;rport=5060;branch=z9hG4bKPj266e06c4-f8c1-407e-b496-5b72fca001e1
Contact: <sip:1092@10.45.220.57:44658>
To: <sip:1092@37.165.21.89;rinstance=7ec5b67d640140bd>;tag=9340ca5c
From: <sip:0033695614152@192.168.1.80:5060>;tag=f9576058-a13a-42ba-b153-28daab4bc16a
Call-ID: d4666d29-f377-4930-9b21-4cd96dce8994
CSeq: 1051 BYE
User-Agent: SessionTalk 6.0
Content-Length: 0

What is 1067? It seems to have changed its RTCP address to be different from its RTP address, which is not something a normal phone can do. It isn’t something I’ve seen before, so I don’t know if Asterisk can cope.

You appear to have screen scraped this, rather than using log files, so I can’t tell if 1067 issued BYE immediately, or if there was a successful call in between.

What is 192.168.1.50?

192.168.1.50 is my PC with 1067 > microSIP softphone.
If I put my 1092 (smartphone) to Wifi it works perfectly with the Opus codec.
Should I generate a log with a successful call (Wifi)?

The trace shows that the softphone is on 192.168.1.254, not 192.168.1.50. What is 192.168.1.254?

I don’t know what it is…
The softphone is configured to use 192.168.1.50 :

So I don’t know why it’s keeping 192.168.1.254 on Asterisk.

I am now testing the PBX on a VPS.
My configuration is the same, I just changed the external IP on pjsip.conf.
When I make a call to 1092 (a friend is connected on the endpoint), there is no audio and no RTP packets.


    -- Executing [1092@Tout:1] Dial("PJSIP/1067-00000008", "PJSIP/1092,20") in new stack
    -- Called PJSIP/1092
    -- PJSIP/1092-00000009 is ringing
       > 0x7fe09c02d220 -- Strict RTP learning after remote address set to: [MY_FRIEND'S EXTERNAL_IP]:4006
    -- PJSIP/1092-00000009 answered PJSIP/1067-00000008
       > 0x7fe09c01e4f0 -- Strict RTP learning after remote address set to: [MY_ EXTERNAL_IP]:4014
    -- Channel PJSIP/1092-00000009 joined 'simple_bridge' basic-bridge <cf7ac329-ebf2-4c6d-8a5b-bd13aeba7744>
    -- Channel PJSIP/1067-00000008 joined 'simple_bridge' basic-bridge <cf7ac329-ebf2-4c6d-8a5b-bd13aeba7744>
       > Bridge cf7ac329-ebf2-4c6d-8a5b-bd13aeba7744: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1067-00000008' and 'PJSIP/1092-00000009' in stack
       > 0x7fe09c01e4f0 -- Strict RTP learning after remote address set to: [MY_ EXTERNAL_IP]:4014
       > Locally RTP bridged 'PJSIP/1067-00000008' and 'PJSIP/1092-00000009' in stack
	   

When me or my friend put the call on hold and resume it, the audio is working perfectly :

Got RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030199, ts 486080, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030104, ts 486400, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030200, ts 486240, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030105, ts 486560, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030201, ts 486400, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030106, ts 486720, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030202, ts 486560, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030107, ts 486880, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030203, ts 486720, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030108, ts 487040, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4014 (type 00, seq 030204, ts 486880, len 000160)
Sent RTP P2P packet to [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, len 000160)
Got  RTP packet from    [MY_FRIEND'S EXTERNAL_IP]:4006 (type 00, seq 030109, ts 487200, len 000160)
Sent RTP P2P packet to [MY_ EXTERNAL_IP]:4014 (type 00, len 000160)

So I have to put the call on hold to get sound.

Is Asterisk receiving media before the hold/unhold? If not, is it sending the correct address in the SDP? Is it sending media? Is it sending to the correct address? Is the correct address in the SDP from the phones?

I just put :
rtp_keepalive=1
on the endpoint and now it’s working.
But with 4G i have the same problem, no sound.
But music on hold is working with 4G.
There are RTP packets :slight_smile:

Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032471, ts 509760, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032472, ts 509920, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032473, ts 510080, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032474, ts 510240, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032475, ts 510400, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032476, ts 510560, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032477, ts 510720, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032478, ts 510880, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032479, ts 511040, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032480, ts 511200, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032481, ts 511360, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032482, ts 511520, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032483, ts 511680, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032484, ts 511840, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032485, ts 512000, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032486, ts 512160, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032487, ts 512320, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032488, ts 512480, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032489, ts 512640, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032490, ts 512800, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032491, ts 512960, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032492, ts 513120, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032493, ts 513280, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)
Got  RTP packet from    [MY_ EXTERNAL_IP]:4006 (type 00, seq 032494, ts 513440, len 000160)
Sent RTP P2P packet to 10.45.220.57:4026 (type 00, len 000160)

I don’t know why it use 10.45.220.57, it’s not my 4G IP address.

My pjsip config file :

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
local_net = 127.0.0.1/32
external_media_address = 185.132.42.245
external_signaling_address = 185.132.42.245

#include users/1067.conf
#include users/1092.conf

My 1067/1092.conf file :

[1067]

type=auth
auth_type=userpass

password=xxxxxxx
username=1067

[1067]

type=endpoint
rtp_keepalive=1
transport=transport-udp
auth=1067
; aors
aors=1067
context=Tout
disallow=all
;allow=opus I temporary disabled opus
allow=ulaw
allow=alaw
call_group=1
pickup_group=1
rewrite_contact = yes
direct_media = no 
force_rport = yes
rtp_symmetric = yes
callerid=0033695614152

[1067]

type=aor
max_contacts=10

Where can I see the SDP’s address ?