No Voice Between PJSIP Extensions registering to EC2 Based Asterisk Server

Hello,

I’ve installed Asterisk on CentOS 7 EC2 instance with elastic public IP. prepared PJSIP AORS,Auths, Endpoints using Realtime ODBC.

I have registered 2 phones from my home network. extensions 1000, 1001

Calling extension from the other, rings. However, I can’t hear voice!

I’ve even tried basic dial plan like this :

[from-internal]
exten => _1XXX,1,NoOp()
same => n,Answer()
same => n,SayAlpha(abc)

It logs playing “character” media files. but no luck hearing these also.

here is my pjsip.conf file contentes:

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

here is a sample data in pj_endpoints table:

id transport aors auth context disallow allow direct_media
1000 transport-udp 1000 1000 from-internal all g722,ulaw,alaw no

I’ve opened ports 5060(TCP+UDP),5061(TCP+UDP), and 10000-20000(UDP) to my home’s gateway Public IP in my EC2 instance’s Security group.

Thanks in advance for help!

You have to configure the transport with local_net and external_media_address and external_signaling_address so the IP address put into the SIP signaling is the public one, and not within your EC2 network.

That was my original PJSIP before going to the simpler above:

[transport-udp-nat]
type = transport
protocol = udp
bind = 0.0.0.0:5060
local_net = [private instance IP]/24
external_media_address = [public instance IP]
external_signaling_address = [public instance IP]
allow_reload = true

* The IP values within brackets above are the correct IPs in the actual config file.

However making calls fails and the CLI logs this :
ERROR[4791]: res_pjsip.c:3427 ast_sip_set_tpselector_from_transport_name: Unable to retrieve PJSIP transport ‘transport-udp’

Your transport is named “transport-udp-nat” and not “transport-udp” with the configuration you just provided.

fixed the transport section name:
when making test calls , I can here voice of “SayAlpha” application. but when the dialplan rings another extension and answer. still no voice can be heard between the two connected parties.

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
external_media_address=xxx.xxx.xxx.xxx ;public ip of ec2 instance
external_signaling_address=xxx.xxx.xxx.xxx ;public ip of ec2 instance
local_net=yyy.yyy.yyy.yyy/32 ;private ip of ec2 instance
local_net=192.168.1.0/24 ;private ip of endpoints (My Local home address range)

this is my modified dialplan :

 [general]
static=yes


[from-internal]
exten => _1XXX,1,NoOp()
same => n,Answer()
same => n,SayAlpha(abc)
same => n,Dial(PJSIP/${EXTEN})

Here is the CLI Log from the time of making a call from Extension 1003 to 1001 (Both SoftPhones registered on remote Asterisk in my PC connected to my homes local Network) :

== Setting global variable 'SIPDOMAIN' to '[HERE IS MY EC2 INSTANCE PUBLIC IP]'
    -- Executing [1001@from-internal:1] NoOp("PJSIP/1003-00000000", "") in new stack
    -- Executing [1001@from-internal:2] Answer("PJSIP/1003-00000000", "") in new stack
       > 0x2c90c80 -- Strict RTP learning after remote address set to: 'HERE IS PUBLIC IP OF MY HOME GATEWAY':4002
       > 0x2c90c80 -- Strict RTP learning after remote address set to: 'HERE IS PUBLIC IP OF MY HOME GATEWAY':4002
    -- Executing [1001@from-internal:3] SayAlpha("PJSIP/1003-00000000", "abc") in new stack
    -- <PJSIP/1003-00000000> Playing 'letters/a.ulaw' (language 'en')
       > 0x2c90c80 -- Strict RTP switching to RTP target address 'HERE IS PUBLIC IP OF MY HOME GATEWAY':4002 as source
    -- <PJSIP/1003-00000000> Playing 'letters/b.ulaw' (language 'en')
    -- <PJSIP/1003-00000000> Playing 'letters/c.ulaw' (language 'en')
    -- Executing [1001@from-internal:4] Dial("PJSIP/1003-00000000", "PJSIP/1001") in new stack
    -- Called PJSIP/1001
    -- PJSIP/1001-00000001 is ringing
    -- PJSIP/1001-00000001 is ringing
       > 0x3fb5f00 -- Strict RTP learning after remote address set to: 'HERE IS PUBLIC IP OF MY HOME GATEWAY':40036
    -- PJSIP/1001-00000001 answered PJSIP/1003-00000000
    -- Channel PJSIP/1001-00000001 joined 'simple_bridge' basic-bridge <43f35ea3-5ae0-40d2-bff0-cd024b359106>
    -- Channel PJSIP/1003-00000000 joined 'simple_bridge' basic-bridge <43f35ea3-5ae0-40d2-bff0-cd024b359106>
       > Bridge 43f35ea3-5ae0-40d2-bff0-cd024b359106: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1003-00000000' and 'PJSIP/1001-00000001' in stack
       > 0x2c90c80 -- Strict RTP learning complete - Locking on source address 'HERE IS PUBLIC IP OF MY HOME GATEWAY':4002
    -- Channel PJSIP/1001-00000001 left 'native_rtp' basic-bridge <43f35ea3-5ae0-40d2-bff0-cd024b359106>
    -- Channel PJSIP/1003-00000000 left 'native_rtp' basic-bridge <43f35ea3-5ae0-40d2-bff0-cd024b359106>
  == Spawn extension (from-internal, 1001, 4) exited non-zero on 'PJSIP/1003-00000000'

Your endpoints are configured to attempt direct media, which may or may not work at times depending on the remote network. Set “direct_media” to “no” in the endpoints.

Thanks for the quick reply !

id transport aors auth context disallow allow direct_media connected_line_method
1001 transport-udp 1001 1001 from-internal all g722,ulaw,alaw no
1003 transport-udp 1003 1003 from-internal all g722,ulaw,alaw no

The direct_media is no

Then I would suggest looking at “rtp set debug on” to see if media is being received and sent between the two.

Thank you @jcolp for your time and help:

it worked after I registered another extension (1002) from my mobile phone, so each phone in the test has a different IP in home network.

As I said my previous test was using 2 different softphones (ext: 1001 and 1003) running on my PC.

So, it worked with the same configs above :slight_smile:

hostname*CLI>
hostname*CLI>
  == Setting global variable 'SIPDOMAIN' to '[EC2 INSTANCE PUBLIC IP]'
    -- Executing [1001@from-internal:1] NoOp("PJSIP/1002-0000000c", "") in new stack
    -- Executing [1001@from-internal:2] Answer("PJSIP/1002-0000000c", "") in new stack
       > 0x7fbe7000c960 -- Strict RTP learning after remote address set to: '[HOME GW PUBLIC IP]':7076
    -- Executing [1001@from-internal:3] SayAlpha("PJSIP/1002-0000000c", "abc") in new stack
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018321, ts 000160, len 000160)
    -- <PJSIP/1002-0000000c> Playing 'letters/a.ulaw' (language 'en')
       > 0x7fbe7000c960 -- Strict RTP switching to RTP target address '[HOME GW PUBLIC IP]':7076 as source
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000004, ts 2800916457, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000005, ts 2800916617, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018322, ts 000320, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018323, ts 000480, len 000160)
.
.
.
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018351, ts 004918, len 000118)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000035, ts 2800921417, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018352, ts 005078, len 000160)
    -- <PJSIP/1002-0000000c> Playing 'letters/b.ulaw' (language 'en')
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000036, ts 2800921577, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018353, ts 005238, len 000160)
.
.

Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000073, ts 2800927497, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018389, ts 010849, len 000011)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018390, ts 011009, len 000160)
    -- <PJSIP/1002-0000000c> Playing 'letters/c.ulaw' (language 'en')
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000074, ts 2800927657, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018391, ts 011169, len 000160)
.
.
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000077, ts 2800928137, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018394, ts 011649, len 000160)
.
.
.
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018432, ts 017729, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000115, ts 2800934217, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018433, ts 017769, len 000040)
    -- Executing [1001@from-internal:4] Dial("PJSIP/1002-0000000c", "PJSIP/1001") in new stack
    -- Called PJSIP/1001
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000116, ts 2800934377, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000117, ts 2800934537, len 000160)
.
.
.
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000125, ts 2800935817, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000126, ts 2800935977, len 000160)
    -- PJSIP/1001-0000000d is ringing
    -- PJSIP/1001-0000000d is ringing
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000127, ts 2800936137, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018434, ts 019625, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000128, ts 2800936297, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018435, ts 019785, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000129, ts 2800936457, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018436, ts 019945, len 000160)
.
.
.
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000228, ts 2800952297, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018536, ts 035945, len 000160)
       > 0x7fbe7000c960 -- Strict RTP learning complete - Locking on source address '[HOME GW PUBLIC IP]':7076
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000229, ts 2800952457, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018537, ts 036105, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000230, ts 2800952617, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018538, ts 036265, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000231, ts 2800952777, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018539, ts 036425, len 000160)
.
.
.
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000311, ts 2800965577, len 000160)
Sent RTP packet to      '[HOME GW PUBLIC IP]':7076 (type 00, seq 018619, ts 049225, len 000160)
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000312, ts 2800965737, len 000160)
       > 0x7fbe7001bcb0 -- Strict RTP learning after remote address set to: '[HOME GW PUBLIC IP]':40018
    -- PJSIP/1001-0000000d answered PJSIP/1002-0000000c
    -- Channel PJSIP/1001-0000000d joined 'simple_bridge' basic-bridge <2fad04bc-93be-4c62-be20-b9631b5e95da>
    -- Channel PJSIP/1002-0000000c joined 'simple_bridge' basic-bridge <2fad04bc-93be-4c62-be20-b9631b5e95da>
       > Bridge 2fad04bc-93be-4c62-be20-b9631b5e95da: switching from simple_bridge technology to native_rtp
       > Locally RTP bridged 'PJSIP/1002-0000000c' and 'PJSIP/1001-0000000d' in stack
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000313, ts 2800965897, len 000160)
Sent RTP P2P packet to '[HOME GW PUBLIC IP]':40018 (type 00, len 000160)
.
.
.
Got  RTP packet from    '[HOME GW PUBLIC IP]':7076 (type 00, seq 000429, ts 2800984457, len 000160)
Sent RTP P2P packet to '[HOME GW PUBLIC IP]':40018 (type 00, len 000160)
    -- Channel PJSIP/1001-0000000d left 'native_rtp' basic-bridge <2fad04bc-93be-4c62-be20-b9631b5e95da>
    -- Channel PJSIP/1002-0000000c left 'native_rtp' basic-bridge <2fad04bc-93be-4c62-be20-b9631b5e95da>
  == Spawn extension (from-internal, 1001, 4) exited non-zero on 'PJSIP/1002-0000000c'
hostname*CLI>