[Home]

Summary:ASTERISK-26280: DNS lookups can block channel media paths
Reporter:Mark Michelson (mmichelson)Labels:
Date Opened:2016-08-09 16:19:35Date Closed:2016-08-10 10:25:19
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Resources/res_rtp_asterisk
Versions:13.10.0 Frequency of
Occurrence
Frequent
Related
Issues:
is duplicated byASTERISK-26487 res_rtp_asterisk: RTP stream frozen when receiving RTCP packets
Environment:Attachments:
Description:When an RTCP packet is sent or received, res_rtp_asterisk generates a Stasis event that contains the RTCP report as well as the local and remote addresses that the report pertains to.

The addresses are determined using {{ast_find_ourip()}}. For the local address, this will typically result in a lookup of the hostname of the server, and then a DNS lookup of that hostname. If you do not have the host in {{/etc/hosts}}, then this results in a full DNS lookup, which can potentially block for some time.

This is especially problematic when performing RTCP reads, since those are done on the same thread responsible for reading and writing media.

A workaround exists. The lookup can be avoided if in {{pjsip.conf}} the endpoint has {{bind_rtp_to_media_address=yes}} and has set an explicit {{media_address}}.
Comments:By: Matt Jordan (mjordan) 2016-08-10 08:29:53.611-0500

Since I'm the one who added the call to {{ast_find_ourip}} into {{res_rtp_asterisk}}, I'll at least note that the reason for doing so was to prevent us from advertising {{0.0.0.0}} as the IP address of Asterisk in RTCP events.

It'd probably be reasonable to just call {{ast_find_ourip}} one time when the RTP instance is created, cache the result, and use it for all subsequent RTCP events.

By: Mark Michelson (mmichelson) 2016-08-10 09:45:01.002-0500

Yep, that's what I'm doing to fix it: https://gerrit.asterisk.org/#/c/3445/