[Home]

Summary:ASTERISK-03575: [patch] Running out of RTP ports due to SUBSCRIBEs (No RTP ports Remaining)
Reporter:sarat (sarat)Labels:
Date Opened:2005-02-24 12:03:54.000-0600Date Closed:2008-01-15 15:26:24.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Subscriptions
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) subscribe-rtp.txt
( 1) subscribe-rtp-u.txt
Description:While trying to deploy a bunch of Polycom IP 500 phones, I ran in to the following.  I limited the RTP ports from 8000-8050 to limit holes in firewall.  Pretty soon Asterisk ran out of RTP ports.  Traced the problem back to how * is handling SUBSCRIBE.  A sip structure is allocated as soon as a request is received, which also allocates RTP ports.  Normally, this is not a problem as the structure is released as soon as the request is answered, which is pretty quick.  However, SUBSCRIBE has an expiry header, till which time * keeps around the call structure and hence hanging on to those RTP ports.  (SUBSCRIBE doesn't even need an RTP port).  This problem is amplified by Polycom "Buddy Lists" as each phone subscribes to changes in extension status of all the "buddy" up to 7 extensions.


****** ADDITIONAL INFORMATION ******

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.665
diff -r1.665 chan_sip.c
8382a8383,8393
>
>                   /*Don't hang on to RTP ports */
>                     if (p->rtp) {
>                          ast_log(LOG_DEBUG,"SUBSCRIBE releasing RTP port\n");
>                          ast_rtp_destroy(p->rtp);
>                     }
>                     if (p->vrtp) {
>                          ast_log(LOG_DEBUG,"SUBSCRIBE releasing VRTP port\n");>                          ast_rtp_destroy(p->vrtp);
>                     }
>
Comments:By: sarat (sarat) 2005-02-24 12:05:48.000-0600

Forgot to mention that above attached file is a patch to fix the problem.

By: Clod Patry (junky) 2005-02-24 12:07:02.000-0600

Please attach a diff -u format.

Do you've disclaimer of file at digium?

By: Brian West (bkw918) 2005-02-24 12:42:02.000-0600

why not increase the port range?

/b

By: Terry Wilson (twilson) 2005-02-24 13:46:09.000-0600

Because it is a bug, Brian... he shouldn't have to.

Also, why does asterisk allocate RTP ports on all requests in the first place?  Shouldn't you only have to alocate an RTP port on a positive reply to a message which contains an SDP message (if it is an inbound message to *) or if asterisk itself is generating a request with an SDP body?

I may be wrong, I'm new at this... :-)

edited on: 02-24-05 13:56

By: sarat (sarat) 2005-02-24 13:58:22.000-0600

Attached a patch file in diff -u format.  I don't have a disclaimer on file.  I'll fax one in.

To answer bkw: Firwall admins don't like opening wide range of ports. Besides, its a resource leak/hog.

By: Mark Spencer (markster) 2005-02-24 18:38:46.000-0600

Patch looks fine.  Just let me know when you've sent in your disclaimer so I can merge it in.  I'm in Miami right now.

By: sarat (sarat) 2005-02-25 16:24:35.000-0600

Disclaimer faxed in. --Sarat.

By: Mark Spencer (markster) 2005-02-25 19:12:19.000-0600

The patch did not apply but I manually fixed it (also set the pointers to NULL to avoid a double free condition).

By: Russell Bryant (russell) 2005-02-27 18:33:21.000-0600

This has been fixed in 1.0, including the fix for the typo from bug ASTERISK-3593.

By: Digium Subversion (svnbot) 2008-01-15 15:26:08.000-0600

Repository: asterisk
Revision: 5082

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r5082 | markster | 2008-01-15 15:26:08 -0600 (Tue, 15 Jan 2008) | 2 lines

Release RTP ports early (bug ASTERISK-3575)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5082

By: Digium Subversion (svnbot) 2008-01-15 15:26:24.000-0600

Repository: asterisk
Revision: 5101

U   branches/v1-0/CHANGES
U   branches/v1-0/channels/chan_sip.c

------------------------------------------------------------------------
r5101 | russell | 2008-01-15 15:26:24 -0600 (Tue, 15 Jan 2008) | 2 lines

release RTP ports early on SUBSCRIBE (bug ASTERISK-3575 / ASTERISK-3593)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5101