Summary:ASTERISK-00326: outgoing limit in chan_sip not working as described
Reporter:Ricardo Villa (ricvil)Labels:
Date Opened:2003-09-28 22:26:40Date Closed:2004-09-25 02:49:15
Versions:Frequency of
Description:outbound calls to an external SIP provider like FWD or Iconnect do not obey outgoing limits.  Local calls do seem to be aware of the defined limits.


I just tried to test this feature with fwd.  I defined an incoming and
outgoing limit of 1.   The following comand verifies it:

*CLI> sip show inuse
Username        incoming        Limit           outgoing        Limit
fwd             0               1               0               1
1010            0               N/A             0               1

I then place a call from 1010 to fwd:

   -- Executing Goto("SIP/1010-7cbd", "fwd1|BYEXTENSION|1") in new stack
   -- Goto (fwd1,22357,1)
   -- Executing Dial("SIP/1010-7cbd", "SIP/22357@fwd") in new stack
   -- Called 22357@fwd
   -- SIP/fwd-6c65 is making progress passing it to SIP/1010-7cbd
   -- SIP/fwd-6c65 answered SIP/1010-7cbd
   -- Attempting native bridge of SIP/1010-7cbd and SIP/fwd-6c65

...and the call connects fine...but the channel limit does not show(and does
not work either since I can place multiple concurrent calls):

*CLI> sip show inuse
Username        incoming        Limit           outgoing        Limit
fwd             0               1               0               1
1010            1               N/A             0               1

If I call a local phone it does seem to work fine.

With DEBUG on it mentions something about the dialed number not being
local...not sure if it is related to the problem though:
DEBUG[12301]: File chan_sip.c, Line 942 (find_user): 22357 is not a local user

*CLI> show version
Asterisk CVS-09/14/03-23:14:08 built by root@maui on a i686 running Linux

It would be very useful if this feature could be fixed.

Comments:By: John Todd (jtodd) 2003-09-29 02:59:05

I will concur that this does not seem to work with an "outgoinglimit" set to 1.  I was able to make similar multiple outbound calls to FWD's answering machine (my test case) despite the limit.  My "outgoing" number never changed away from "0" even with 2 channels active.

By: John Todd (jtodd) 2003-09-29 03:01:10

I have re-opened the feature request for this:  http://bugs.digium.com/bug_view_page.php?bug_id=0000098

By: patrick (patrick) 2003-09-29 05:36:30

Incominglimit = number of calls the local extension can originate to Asterisk.
Outgoinglimit = number of calls Asterisk will terminate to local extension.

It's from the viewpoint of the Asterisk PBX, not from the local extension.  

Look at the counters above and note that when the call was placed to FWD from the local extension, the incoming counter increased (which, by the way, has a limit of N/A).

You should set the incominglimit=1 in the sip.conf if you wanted to limited the number of calls to FWD's answering machine.  Did the incoming counters change when you did this test?

Maybe to cause less confusion, it should be changed to originatelimit and terminatelimit?

By: Ricardo Villa (ricvil) 2003-09-29 10:06:09

I set incominglimit=1 and outgoinglimit=1 for the fwd entry in sip.conf.  But it will not obey it.  It seems that this feature only works for "local" extensions.  Any chance to make it work with "non-local" entries like FWD or Iconnect?


By: patrick (patrick) 2003-09-29 15:31:08

Can you post your config for fwd in sip.conf?

By: Ricardo Villa (ricvil) 2003-09-29 15:37:56

Sure...here it is:

and in extensions.conf (for dialing 1800 numbers for example):
exten => _018XXXXXXXXX,1,Dial,SIP/${EXTEN:1}@fwd

By: John Todd (jtodd) 2003-09-29 19:39:17

I have similar configurations in my peer configuration for FWD.  The "outgoing" number never changes in "sip show inuse" no matter how many calls I have going to FWD.

By: patrick (patrick) 2003-09-29 23:42:03

Okay, now I see what fwd is - it's basically a peer (although, with type=friend it is defined in both sip_peer and sip_user structures).  type=user sip entity can only send calls through the Asterisk PBX (incominglimit would apply), while type=friend means that the sip entity is able to both send and receive calls (incominglimit and outgoinglimit).

Also, since @fwd puts the fwd in the rhs to determine what host to send the INVITE, what is compared is the lhs (${EXTEN:1} to the local users table.

As a test (if you don't mind):
-- sip.conf
change the [fwd] to [22357]
leave type=friend
-- extensions.conf
exten => _018XXXXXXXXX,1,Dial,SIP/${EXTEN:1}@fwd to exten => _018XXXXXXXXX,1,Dial,SIP/${EXTEN:1}@22357

This should define 22357 in both sip_peer and sip_user and the @22357 should send the call to fwd.pulver.com with a outgoinglimit counter incremented on 22357

Oddly enough, when I set type=peer, I can still send and receive calls (I should not be able to since that isn't how type=peer is defined - only Asterisk sending calls is allowed).  However, because there is no limit definition for the sip_peer stucture, it will not show up in "sip show inuse".

The patch works as it should for a "local" user, setting limits based on sip_peer is a different patch.

By: Ricardo Villa (ricvil) 2003-09-30 01:41:54

ok...my fwd number is 20771 so I changed it to look like this:

and extensions.conf to this:
exten => _01877XXXXXXX,1,Dial,SIP/${EXTEN:1}@20771

I then call Digium from line 1002:
   -- Executing Dial("SIP/1002-11f2", "SIP/18775468963@20771") in new stack
   -- Called 18775468963@20771
   -- SIP/20771-14f0 answered SIP/1002-11f2
   -- Attempting native bridge of SIP/1002-11f2 and SIP/20771-14f0
sip show inuse
Username        incoming        Limit           outgoing        Limit
20771           0               1               0               1
1002            1               N/A             0               N/A

But the outgoing limit for 20771 is not incremented.

But if I change the fwd entry to the exact number I dialed like this:

and extension.conf like this:
exten => _01877XXXXXXX,1,Dial,SIP/${EXTEN:1}@18775468963

It works fine...but that really does not serve any purpose as the idea is to be able to dial any FWD number, ICH Number...etc...

Can you get this patch to work with a Peer...I think that's were it would be most useful.


By: John Todd (jtodd) 2003-10-01 13:26:15

I would agree.  I am not sure what purpose this would serve with just local users, or certainly it seems like it has very limited use for an otherwise very nice idea.  It seems most useful if this would work on all SIP peer definitions in sip.conf, since most people are only trying to limit their sessions outbound across a WAN to an ITSP or gateway of some sort.   I am uncertain what "local" means in this context, as well.  My * server should have no idea what the difference is between a SIP gateway, an ITSP, or any other device other than what I have in the "type=" statement.

By: patrick (patrick) 2003-10-02 06:30:01

Local refers to a SIP entity which registers with the Asterisk Server.  I did have a need for the patch.

Unfortunately, right now I don't have a lot time to do the patch for peers, but I will see if I can get it done.

By: John Todd (jtodd) 2003-10-02 14:25:14

OK, whenever you have the time and inclination.  It does seem like a very useful patch for peers, since that is the "trunk" on which most people (I expect) will have a requirement to limit outgoing connections.  Of course, this can be done with DBPut/DBGet hacks, but that is really, really ugly and prone to counter corruption in unexpected closure situations (crashes.)

By: scaredycat (scaredycat) 2003-11-26 10:33:47.000-0600

Can we make this a feature of ALL the VoIP protocols... ie IAX, SIP et all... very useful, but I can't get it to work.


By: Brian West (bkw918) 2003-11-26 14:59:29.000-0600