[Home]

Summary:ASTERISK-13854: No RTP ports remaining. Can't setup media stream for this call.
Reporter:Lam Soft (lamsoft)Labels:
Date Opened:2009-03-29 10:19:38Date Closed:2009-04-27 08:57:30
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I'm running Asterisk on VMWare under Windows 2003 Server using VMWare NAT.
Because I have to input the port mapping manually (Asterisk is behind NAT), I just assigned 26 ports from 20000 - 20025, but I think it is enough for me to use because I just have 3 SIP peers.

reinvite set to "no" in sip.conf

There are two PSTN account,
one is VOIP type, provided by my ISP, the number is 3xxx-xxxx
and the other one is using Linksys SPA-3102, physically connected to a PSTN line provided by my service provider, the number is 2xxx-xxxx

When I run "netstat -nap | grep asterisk", there are no RTP port being used initially.
I call the PSTN number 3xxx-xxxx, 2 RTP ports assigned, and the rule is forward to a voice menu to select which extension you want to call, I enter the extension number, 6 RTP ports assigned, when I disconnect the call, there are 2 RTP ports using, it seems ok that ASTERISK know the call is disconnected and release that RTP port.

But if I call the PSTN Number 2xxx-xxxx, my ATA-Box forward that call to asterisk, and same, select the extension to call, after that, 8 RTP ports being used, and after disconnect the call, asterisk does not release the RTP ports, and so on more and more ports are being used and finally an error is shown in "asterisk -r":

[Mar 28 23:24:17] ERROR[9140]: rtp.c:2517 ast_rtp_new_with_bindaddr: No RTP ports remaining. Can't setup media stream for this call.
[Mar 28 23:24:17] WARNING[9140]: chan_sip.c:6272 sip_alloc: Unable to create RTP audio session: Address already in use

What I can do is either "core restart now" or "service asterisk restart" to force asterisk to release all the RTP port.

****** STEPS TO REPRODUCE ******

Note: 192.168.0.4 is the IP of asterisk
192.168.0.250 is the Linksys SPA-3102 ATA Box
Initially
[root@lamsoft-pbx ~]# netstat -nap | grep asterisk
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:5038                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5080          ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:42540           192.168.0.1:3306            ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5060          ESTABLISHED 23935/asterisk
udp        0      0 0.0.0.0:5000                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:2727                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4520                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4569                0.0.0.0:*                               23935/asterisk
-----------------------------------------------------------------
I call the number 2xxx-xxxx, and not yet select the extension to call:
[root@lamsoft-pbx ~]# netstat -nap | grep asterisk
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:5038                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5080          ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:42540           192.168.0.1:3306            ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5060          ESTABLISHED 23935/asterisk
udp        0      0 0.0.0.0:5000                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:2727                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4520                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20022               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20023               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20024               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20025               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4569                0.0.0.0:*                               23935/asterisk
----------------------------------------------------------------
select the extension to call, 2 more RTP ports used
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:5038                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5080          ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:42540           192.168.0.1:3306            ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5060          ESTABLISHED 23935/asterisk
udp        0      0 0.0.0.0:5000                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20004               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20005               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:2727                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4520                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20022               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20023               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20024               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20025               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4569                0.0.0.0:*                               23935/asterisk
-------------------------------------
After disconnect the call, and around 60s later, there are still 4 ports being used:
[root@lamsoft-pbx ~]# netstat -nap | grep asterisk
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:5038                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5080          ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:42540           192.168.0.1:3306            ESTABLISHED 23935/asterisk
tcp        0      0 192.168.0.4:5060            192.168.0.250:5060          ESTABLISHED 23935/asterisk
udp        0      0 0.0.0.0:5000                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20004               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20005               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:2727                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4520                0.0.0.0:*                               23935/asterisk
udp     3672      0 0.0.0.0:20022               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:20023               0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               23935/asterisk
udp        0      0 0.0.0.0:4569                0.0.0.0:*                               23935/asterisk



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

After the disconnection, there are some information hopefully helpful:

lamsoft-pbx*CLI> sip show channels
Peer             User/ANR    Call ID          Format           Hold     Last Message    Expiry
192.168.0.250    (None)      6c7f7ed3-f44a09  0x0 (nothing)    No       Rx: REGISTER
192.168.0.250    (None)      3eae4b4a-89cd4f  0x0 (nothing)    No       Rx: REGISTER

lamsoft-pbx*CLI> sip show peers
Name/username              Host            Dyn Nat ACL Port     Status
1300/1300                  (Unspecified)    D   N      5060     Unmonitored
1314/1314                  192.168.0.250    D          5080     Unmonitored
1315/1315                  192.168.0.5      D   N      6038     Unmonitored
2100/2100                  (Unspecified)    D   N      5060     Unmonitored
5200/5200                  60.50.60.42      D   N      5070     Unmonitored
6000/6000                  (Unspecified)    D   N      5060     Unmonitored
HKBN_PSTN/HKBN_PSTN        192.168.0.250    D          5060     OK (17 ms)

lamsoft-pbx*CLI> sip show subscriptions
Peer             User        Call ID          Extension        Last state     Type            Mailbox    Expiry
0 active SIP subscriptions

lamsoft-pbx*CLI> sip show users
Username                   Secret           Accountcode      Def.Context      ACL  NAT

lamsoft-pbx*CLI> sip show tcp
Host                           Port Transport   Type
192.168.0.250                  5080   TCP       Server
192.168.0.250                  5060   TCP       Server

lamsoft-pbx*CLI> sip show inuse
* Peer name               In use          Limit
6000                      0/0/0           100
1314                      0/0/0           100
1315                      0/0/0           100
2100                      0/0/0           100
1300                      0/0/0           100
Comments:By: Lam Soft (lamsoft) 2009-03-30 10:26:51

Sorry may be my poor english, a SWF video is uploaded for easier understanding.
After finish each call, 2 more UDP ports is being occupied and didn't release, and so on finally all the RTP ports was being used and cannot make a new call.

Thank you.

Download Link: http://www.sendspace.com/file/gm8rex (5.05MB)

HKBN_PSTN Trunk Setup in users.conf
[HKBN_PSTN]
disallow = all
allow = ulaw,alaw
context = DID_HKBN_PSTN
canreinvite = no
hasexten = no
hasiax = no
hassip = yes
host = dynamic
type = peer
qualify = yes
registeriax = no
registersip = no
secret = password
trunkname = HKBN_PSTN
trunkstyle = customvoip
username = HKBN_PSTN
insecure = port,invite
dtmfmode = inband
nat = no
transport = tcp,udp

By: Lam Soft (lamsoft) 2009-04-05 20:30:32

May I know any one can re-produce this issue?
I have to schedule to restart the asterisk at mid-night to prevent the ports are all used....

By: Leif Madsen (lmadsen) 2009-04-09 12:03:17

I have it assigned to me to reproduce this issue, but I haven't had a chance to do it this week due to a presentation I gave yesterday, and am now catching up today. Also Friday is a holiday here in Canada.

By: Lam Soft (lamsoft) 2009-04-10 00:02:59

Thank you very much.
I just scare no one understand what i said...
I tried to solve it myself, but due to my poor programming skill, I just can trace asterisk will create two UDP (RTP and RTCP), but not able to trace in what condition asterisk will destroy these two UDP ports..
I hope the issue will be fixed soon :)

By: Joshua C. Colp (jcolp) 2009-04-20 12:11:29

Please update to the latest SVN and try again. I just put in a change to fix a memory leak of SIP dialogs on TCP and TLS calls. You may have been exceeding the available memory.

By: Joshua C. Colp (jcolp) 2009-04-27 08:57:29

After further examination of the provided information this fits perfectly with what I fixed. I am quite confident this has been fixed by my commit.