PJSIP Direct media issue

Hi all,

I understood that PJSIP uses direct media by default for calling between extensions.
We have a hosted PBX and the endpoints are behind NAT.
Not sure how FreePBX decides when to send the RTP traffic directly and not via the PBX?

Let’s say we have 2 extensions, located in 2 different locations with their own public IP and ISP.
Why would FreePBX try to send the media directly to the internal IP? It will never work, since there is no connectivity between the 2 LAN networks…

In the new Core version, we can set the global setting for direct media to NO, but this only applies to new extensions. How can we (bulk) change this for all existing extensions?


Make sure you are using the latest version of Core module.
Export all extensions via the Bulk Handler
Change the value of ‘direct_media’ to ‘no’

Import the extensions into FPBX via the Bulk handler.

Where is said global setting found?

Under Advanced Settings:

Downside is this only applies to new extensions…

No, that has nothing to do with PJSIP. Those settings existed before PJSIP, have existed after PJSIP because those settings apply to IAX and Chan_SIP, both of which have Global Settings that apply to all their peers. PJSIP does not have global endpoint settings that all the endpoints can just use.

There is an option now under the Advanced Tab under the Extensions settings to now be able to disable/enable Direct Media on PJSIP extensions. New or current. It still defaults to “Yes” because that is the Asterisk default for it.

Aha, very clear… thanks!

Then the question remains: How does FreePBX decides when to send the RTP traffic directly and not via the PBX?

The configuration controls whether the functionality is enabled or not. There is no decisioning past that.

Should I add a feature request to only send the media directly if the public IP of the registered extension is the same? :wink:

The Asterisk project itself does not currently do feature request bugs. You can try to elicit interest in the Asterisk community forum and see if someone wants to approach it. Generally most individuals are perfectly fine with media going through the PBX or they use features which force. In other cases they tightly control things and can guarantee certain conditions. That’s most likely why noone has really expanded it.


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