Hello Asterisk Community,
I have been struggling for weeks with an issue related to RTP configuration and channel variables when using the chan_rtp channel driver. Here is a detailed description of the problem:
My Setup:
asterisk 20.11.0 with freepbx16
• Modules loaded (output of module show like rtp):
bridge_native_rtp.so Native RTP bridging module
chan_rtp.so RTP Media Channel
res_pjsip_sdp_rtp.so PJSIP SDP RTP/AVP stream handler
res_rtp_asterisk.so Asterisk RTP Stack
res_rtp_multicast.so Multicast RTP Engine
res_srtp.so Secure RTP (SRTP)
All modules are running.
• Dialplan (simplified):
[from-viadialog-custom]
exten => s,1,Set(MEDIA_CHANNEL_UUID=${STRFTIME(,%Y%m%d-%H%M%S)}-${RAND()})
same => n,Stasis(callbotai1,${CALLERID(num)},${MEDIA_CHANNEL_UUID})
same => n,Hangup()
• ARI External Media Channel Code:
this.ari.channels.externalMedia({
app: “callbotai1”,
external_host: “127.0.0.1:12345”,
format: “slin16”,
direction: “both”,
encapsulation: “rtp”,
});
The Issue:
- The channel variables UNICASTRTP_LOCAL_ADDRESS and UNICASTRTP_LOCAL_PORT are not being set.
o Logs show ChannelVarset events for other variables, but UNICASTRTP_LOCAL_ADDRESS and UNICASTRTP_LOCAL_PORT never appear.
o Example:
ChannelVarset event details Variable defined: STASISSTATUS=
The STASISSTATUS variable is empty. - RTP debugging shows no evidence of a local IP or port being allocated by Asterisk for media. The expected variables for local RTP details are not generated.
- My logs show repeated attempts to retrieve the RTP variables, but they always fail:
2024-12-08 17:13:21 warn: Attempt 1/5: RTP variables incomplete
2024-12-08 17:13:21 warn: Attempt 5/5: RTP variables incomplete
2024-12-08 17:13:21 error: Failed to retrieve RTP information - When attempting to find occupied ports, no RTP port appears to be in use:
2024-12-08 17:13:21 info: Port 31500 is AVAILABLE.
…
2024-12-08 17:13:21 info: Port 31600 is AVAILABLE. - This results in an error when setting up the media channel:
2024-12-08 17:13:21 error: Failed to setup media channel for channel ID 1733674400.0: Failed to retrieve RTP information
Logs Summary:
Here are some relevant log excerpts: - Channel Execution:
– Executing [s@from-viadialog-custom:1] NoOp(“PJSIP/Trunk_Viadialog-00000009”, “DEBUG: Incoming call with undefined DID”)
– Executing [s@from-viadialog-custom:5] Stasis(“PJSIP/Trunk_Viadialog-00000009”, “callbotai1,0787000000,0787000000,20241204-182119-813536428”)
– Called 127.0.0.1:12345/c(slin16) - Strict RTP Learning:
0x7f2f40017d30 – Strict RTP learning after remote address set to: 91.213.79.174:12116
0x7f2f040031b0 – Strict RTP learning after remote address set to: 127.0.0.1:12345
- Media Channel Setup:
2024-12-08 17:13:21 error: Failed to setup media channel for channel ID 1733674400.0: Failed to retrieve RTP information
What I Have Tried:
- Activating RTP debugging:
rtp set debug on
No logs about sending or receiving RTP packets are shown. - Checking for UNICASTRTP_LOCAL_ADDRESS and UNICASTRTP_LOCAL_PORT via ARI ChannelVarset events:
o These variables are never set, even after multiple retries. - Inspecting the RTP configuration:
rtp show settings
My configuration is standard, with the range 10000-20000 set in rtp.conf. - Ensuring that chan_rtp.so is loaded and active.
Summary:
It seems that the chan_rtp channel driver is not setting the UNICASTRTP_LOCAL_ADDRESS and UNICASTRTP_LOCAL_PORT channel variables as expected. Without these variables, my application cannot determine where Asterisk expects to receive media, causing failures in the media channel setup.
Could this be a bug, a misconfiguration, or a misunderstanding of how RTP variables are managed in chan_rtp? Any guidance or troubleshooting tips would be greatly appreciated.
Let me know if you need further details about my configuration or logs. Thank you in advance for your help!
Update: Observations Regarding chan_rtp Usage
After further investigation, I noticed that the chan_rtp module is not being utilized when creating an External Media Channel via ARI. Here are the additional details:
1. Expected Behavior
- When using
chan_rtp
, I would expect Asterisk to allocate a local RTP port (from the range defined inrtp.conf
) and set the following channel variables:UNICASTRTP_LOCAL_ADDRESS
UNICASTRTP_LOCAL_PORT
- These variables should indicate the local IP and port where Asterisk is ready to receive RTP traffic.
2. Observed Behavior
- Despite the chan_rtp module being loaded and active (confirmed via
module show like rtp
), these variables are not set. - The RTP handling seems to bypass
chan_rtp
, as Asterisk directly redirects the RTP to the address specified inexternal_host
during theexternalMedia
API call.
3. Debugging Steps Taken
- RTP Debugging Enabled: I enabled
rtp set debug on
but observed no logs indicating local RTP port allocation or packets being sent/received by Asterisk. - Channel Variables Missing: I monitored
ChannelVarset
events via ARI and found noUNICASTRTP_*
variables being defined for the External Media Channel. Example:
ChannelVarset event details Variable defined: STASISSTATUS=
The STASISSTATUS
variable is empty, and no other RTP-related variables are present.
- Dialplan and ARI Configurations: I confirmed that the
direction
parameter inexternalMedia
is set to"both"
and theexternal_host
is correctly specified. However, Asterisk does not seem to allocate local RTP ports for media.
4. Possible Explanation
- It seems that when using
externalMedia
, Asterisk treats the RTP handling as fully externalized and does not allocate or expose local RTP details.
New Questions for the Community
- Is this behavior expected when using
externalMedia
via ARI? Shouldchan_rtp
still allocate local RTP ports for incoming traffic? - Are there additional configurations required to force Asterisk to set the
UNICASTRTP_LOCAL_*
variables during the creation of an External Media Channel? - Could this be related to a bug or limitation in certain Asterisk versions? (I am using asterisk 20.11.0)
Any insights or similar experiences would be greatly appreciated.