Direct Media on PJSIP Trunk

Hi there ,

Is it possible to have direct media/rtp flow between

a) a phone registered on FreePBX and external destination connected over PJSIP Trunk ?
b) two externals phones not registered on FreePBX . Call comes in from one PJSIP trunk and goes out via another PJSIP Trunk ?

For case b I have tried enabling direct media in Trunk >>PJSIP settings >>Advanced. Unfortunately It didn’t work .

Sorry I missed to mention that I am using FreePBX 14.0.5.25 on AWS

PJSIP has direct_media enabled by default. So it would need to be turned off to stop using it. Since there is nothing in the extensions settings to disable or enable this, it would just be “on” because that is the default setting for it.

I made sure that direct media is set to 'YES" in Trunk>>PJSIP settings>>Advanced .
Also in settings>>Advanced settings(on top) ‘SIP canrenivite (directmedia)’ set to ‘yes’.

Unfortunately my media is still flowing via FreePBX. Anything else I need to check?

OK and why would you want direct media to begin with? You are on AWS, that’s behind NAT. Your endpoints are behind NAT. You never, ever want to do direct media between two NAT’d endpoints over the Internet.

There should be zero direct media happening on this box because there is NAT involved.

I have a elsatic IP for this instance on AWS. Its not behind NAT. Yes My phone which is registered on PBX is behind NAT. I want to have media flow direct from my phone to my service provider (connected via Trunk) and vice versa.

The purpose is to reduce media processing on FreePBX.

You do that by matching codecs from the Endpoint through to SIP trunk. Nothing else matters. At that point nothing is being processed by the PBX. it is simply letting call flow through.

I do not know why people keep insisting that their servers on AWS are not behind NAT. Every single EC2 instance that is rolled out is assigned an RFC1918 Address. Those would be the non-public-routable IP subnets like 10.0.0.0/8, 192.168.0.0/16 and the 172.16.0.0-172.32.0.0 ranges. These are Private IP that cannot be routed over the public Internet.

That same server is then assigned a public IP that, guess what, translates to the private IP. I don’t care if it is that “1-to-1 NAT” people like to talk about but even in that name, NAT is there. A public IP is being translated to a private IP on a private network. That is 100% the definition of NAT.

Direct Media is usually not a good idea, being complicated to set up and subject to many issues.

If it’s just to reduce load on the PBX: Note that if Asterisk is recording the call, listening for DTMF (T or t options) or transcoding, you obviously can’t use direct media. If it’s not doing any of those, the per-call load is very small; an AWS Nano instance can handle ~8 concurrent calls.

OTOH, if you’re calling from Bangkok to Bali and the PBX is in Boston, latency will be awful and it’s tempting to use direct media. But trust me, it’s really tough, some features such as call transfer may not work right (depending on provider) and it makes debugging really difficult. You may also see calls fail because the provider’s firewall blocks traffic from the country you are in. Been there, done that.

If you still want to use direct media, I’ll outline the requirements.

Now that I have understood that my box is behind NAT and after listening to your suggestions above I feel like I have to rethink about enabaling direct media.

Thanks Everyone @BlazeStudios @sorvani and @Stewart1 !!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.