Limit number of watchers in asterisk BLF/subscriptions

Our asterisk have been taking toll since number of subscriptions are too many.

is there is way to limit “watchers”

I have looked on internet but nothing specifically touches this topic of limiting number of subscriptions.

E.g.

Only max of 3 phones can subscribe to BLF/monitor to phone 001

Below is part output from our console.

asterisk -rx ‘core show hints’

641@25550094-Default : SIP/6172 State:Idle Watchers 7

643@25550094-Default : SIP/6172 State:Idle Watchers 7

279@25790053-Default : SIP/6128 State:Idle Watchers 5

777@81560062-DEFAULT : SIP/6188 State:Unavailable Watchers 1

799@81560105-DEFAULT : SIP/6188 State:Unavailable Watchers 0

387@81560085-DEFAULT : SIP/6187 State:Idle Watchers 8

683@81560037-DEFAULT : SIP/6188 State:Unavailable Watchers 0

544@81560083-DEFAULT : SIP/6188 State:Unavailable Watchers 0

001@25550042-Default : SIP/6129 State:Idle Watchers 13

002@25550042-Default : SIP/6129 State:Idle Watchers 13

There is nothing built in to limit that.

Any other way to achieve this ?

I did work at work at company who were able to restrict subscriptions. I was not around when this was build so do not know how was this done.

Any ideas will be handy.

If you’re the one provisioning the phones, you’ll have to keep track of that. I have a whole lot more subscriptions than that and it doesn’t seem to affect the server (Intel NUC i7) very much at all. Here’s the output from one of my servers:

asterisk-twc01*CLI> core show hints

    -= Registered Asterisk Dial Plan Hints =-
63001@hints         : SIP/63001             State:Idle            Presence:not_set         Watchers  7
63002@hints         : SIP/63002             State:Idle            Presence:not_set         Watchers  7
63003@hints         : SIP/63003             State:Idle            Presence:not_set         Watchers  7
63004@hints         : SIP/63004             State:Idle            Presence:not_set         Watchers  7
63005@hints         : SIP/63005             State:Idle            Presence:not_set         Watchers  7
63006@hints         : SIP/63006             State:Idle            Presence:not_set         Watchers  7
63007@hints         : SIP/63007             State:Idle            Presence:not_set         Watchers  7
63008@hints         : SIP/63008             State:Idle            Presence:not_set         Watchers  7
10026@hints         : Custom:10026@hints    State:Idle            Presence:not_set         Watchers 23
10027@hints         : Custom:10027@hints    State:Idle            Presence:not_set         Watchers 23
10024@hints         : Custom:10024@hints    State:Idle            Presence:not_set         Watchers  3
10025@hints         : Custom:10025@hints    State:Idle            Presence:not_set         Watchers 23
10022@hints         : Custom:10022@hints    State:Idle            Presence:not_set         Watchers  8
10023@hints         : Custom:10023@hints    State:Idle            Presence:not_set         Watchers  3
10028@hints         : Custom:10028@hints    State:Idle            Presence:not_set         Watchers 23
10029@hints         : Custom:10029@hints    State:Idle            Presence:not_set         Watchers  4
10015@hints         : Custom:10015@hints    State:Idle            Presence:not_set         Watchers  4
10014@hints         : Custom:10014@hints    State:Idle            Presence:not_set         Watchers  4
10017@hints         : Custom:10017@hints    State:Idle            Presence:not_set         Watchers  2
10016@hints         : Custom:10016@hints    State:Idle            Presence:not_set         Watchers  2
10011@hints         : Custom:10011@hints    State:Idle            Presence:not_set         Watchers 14
10010@hints         : Custom:10010@hints    State:Idle            Presence:not_set         Watchers 14
10013@hints         : Custom:10013@hints    State:Idle            Presence:not_set         Watchers  4
10012@hints         : Custom:10012@hints    State:Idle            Presence:not_set         Watchers 14
61112@hints         : SIP/61112             State:Idle            Presence:not_set         Watchers 17
61113@hints         : SIP/61113             State:Idle            Presence:not_set         Watchers 17
61110@hints         : SIP/61110             State:Unavailable     Presence:not_set         Watchers 17
61111@hints         : SIP/61111             State:Idle            Presence:not_set         Watchers 17
61116@hints         : SIP/61116             State:Idle            Presence:not_set         Watchers 17
61117@hints         : SIP/61117             State:Idle            Presence:not_set         Watchers 17
61114@hints         : SIP/61114             State:Idle            Presence:not_set         Watchers 17
61115@hints         : SIP/61115             State:Unavailable     Presence:not_set         Watchers 17
61118@hints         : SIP/61118             State:Idle            Presence:not_set         Watchers 17
61119@hints         : SIP/61119             State:Idle            Presence:not_set         Watchers 17
61121@hints         : SIP/61121             State:Idle            Presence:not_set         Watchers 17
61120@hints         : SIP/61120             State:Idle            Presence:not_set         Watchers 17
61123@hints         : SIP/61123             State:Idle            Presence:not_set         Watchers 17
61122@hints         : SIP/61122             State:InUse           Presence:not_set         Watchers 17
61125@hints         : SIP/61125             State:Unavailable     Presence:not_set         Watchers 17
61124@hints         : SIP/61124             State:Idle            Presence:not_set         Watchers 17
61127@hints         : SIP/61127             State:Idle            Presence:not_set         Watchers 17
61126@hints         : SIP/61126             State:Unavailable     Presence:not_set         Watchers 17
10037@hints         : Custom:10037@hints    State:Idle            Presence:not_set         Watchers 33
10036@hints         : Custom:10036@hints    State:Idle            Presence:not_set         Watchers 33
10035@hints         : Custom:10035@hints    State:Idle            Presence:not_set         Watchers 33
10034@hints         : Custom:10034@hints    State:Idle            Presence:not_set         Watchers  8
10033@hints         : Custom:10033@hints    State:Idle            Presence:not_set         Watchers  8
10032@hints         : Custom:10032@hints    State:Idle            Presence:not_set         Watchers  8
10031@hints         : Custom:10031@hints    State:Idle            Presence:not_set         Watchers  4
10030@hints         : Custom:10030@hints    State:Idle            Presence:not_set         Watchers  4
10038@hints         : Custom:10038@hints    State:Idle            Presence:not_set         Watchers 33
_10XXX@hints        : Custom:${EXTEN}@hint  State:Unavailable     Presence:                Watchers  0
61103@hints         : SIP/61103             State:Idle            Presence:not_set         Watchers 17
61102@hints         : SIP/61102             State:Idle            Presence:not_set         Watchers 17
61101@hints         : SIP/61101             State:Idle            Presence:not_set         Watchers 17
61107@hints         : SIP/61107             State:Idle            Presence:not_set         Watchers 16
61106@hints         : SIP/61106             State:InUse           Presence:not_set         Watchers 17
61105@hints         : SIP/61105             State:Idle            Presence:not_set         Watchers 17
61104@hints         : SIP/61104             State:Idle            Presence:not_set         Watchers 17
61109@hints         : SIP/61109             State:Idle            Presence:not_set         Watchers 17
61108@hints         : SIP/61108             State:Idle            Presence:not_set         Watchers 17
61031@hints         : SIP/61031             State:Ringing         Presence:not_set         Watchers  6
61030@hints         : SIP/61030             State:InUse           Presence:not_set         Watchers  5
61033@hints         : SIP/61033             State:Idle            Presence:not_set         Watchers  3
61035@hints         : SIP/61035             State:Idle            Presence:not_set         Watchers  4
61034@hints         : SIP/61034             State:Idle            Presence:not_set         Watchers  4
_ZXXXX@hints        : SIP/${EXTEN}          State:Unavailable     Presence:                Watchers  0
61036@hints         : SIP/61036             State:Idle            Presence:not_set         Watchers  3
61020@hints         : SIP/61020             State:Idle            Presence:not_set         Watchers  3
61021@hints         : SIP/61021             State:Idle            Presence:not_set         Watchers  3
61022@hints         : SIP/61022             State:Idle            Presence:not_set         Watchers  3
61023@hints         : SIP/61023             State:Idle            Presence:not_set         Watchers 11
61024@hints         : SIP/61024             State:Idle            Presence:not_set         Watchers  3
61025@hints         : SIP/61025             State:InUse           Presence:not_set         Watchers  4
61026@hints         : SIP/61026             State:Idle            Presence:not_set         Watchers  5
61027@hints         : SIP/61027             State:Idle            Presence:not_set         Watchers  4
61028@hints         : SIP/61028             State:Idle            Presence:not_set         Watchers  7
61029@hints         : SIP/61029             State:Ringing         Presence:not_set         Watchers  5
61013@hints         : SIP/61013             State:InUse           Presence:not_set         Watchers  3
64124@hints         : SIP/64124             State:Idle            Presence:not_set         Watchers  4
61012@hints         : SIP/61012             State:InUse           Presence:not_set         Watchers  3
61011@hints         : SIP/61011             State:Idle            Presence:not_set         Watchers  3
64125@hints         : SIP/64125             State:Idle            Presence:not_set         Watchers  5
64126@hints         : SIP/64126             State:Idle            Presence:not_set         Watchers  4
61017@hints         : SIP/61017             State:Idle            Presence:not_set         Watchers  3
64127@hints         : SIP/64127             State:Idle            Presence:not_set         Watchers  5
64120@hints         : SIP/64120             State:Idle            Presence:not_set         Watchers  4
61016@hints         : SIP/61016             State:Idle            Presence:not_set         Watchers  3
61015@hints         : SIP/61015             State:Idle            Presence:not_set         Watchers  3
64121@hints         : SIP/64121             State:Idle            Presence:not_set         Watchers  5
61014@hints         : SIP/61014             State:Idle            Presence:not_set         Watchers  3
64122@hints         : SIP/64122             State:Idle            Presence:not_set         Watchers  4
64123@hints         : SIP/64123             State:Idle            Presence:not_set         Watchers  4
61019@hints         : SIP/61019             State:Idle            Presence:not_set         Watchers  3
61018@hints         : SIP/61018             State:Idle            Presence:not_set         Watchers  3
64128@hints         : SIP/64128             State:Idle            Presence:not_set         Watchers  5
64129@hints         : SIP/64129             State:Idle            Presence:not_set         Watchers  5
_7XXXX@hints        : Custom:${EXTEN}@hint  State:Unavailable     Presence:                Watchers  0
61002@hints         : SIP/61002             State:Idle            Presence:not_set         Watchers  6
61003@hints         : SIP/61003             State:Idle            Presence:not_set         Watchers  6
61000@hints         : SIP/61000             State:Ringing         Presence:not_set         Watchers  7
61001@hints         : SIP/61001             State:Idle            Presence:not_set         Watchers  4
61006@hints         : SIP/61006             State:Idle            Presence:not_set         Watchers  5
61007@hints         : SIP/61007             State:Idle            Presence:not_set         Watchers  4
61004@hints         : SIP/61004             State:Idle            Presence:not_set         Watchers  6
61005@hints         : SIP/61005             State:Idle            Presence:not_set         Watchers  6
61008@hints         : SIP/61008             State:Idle            Presence:not_set         Watchers  4
61009@hints         : SIP/61009             State:Idle            Presence:not_set         Watchers  3
64106@hints         : SIP/64106             State:Idle            Presence:not_set         Watchers  5
64107@hints         : SIP/64107             State:Idle            Presence:not_set         Watchers  5
64104@hints         : SIP/64104             State:Idle            Presence:not_set         Watchers  5
64105@hints         : SIP/64105             State:Idle            Presence:not_set         Watchers  5
64102@hints         : SIP/64102             State:Idle            Presence:not_set         Watchers  5
61070@hints         : SIP/61070             State:Idle            Presence:not_set         Watchers  1
64103@hints         : SIP/64103             State:Idle            Presence:not_set         Watchers  5
64101@hints         : SIP/64101             State:InUse           Presence:not_set         Watchers  4
64108@hints         : SIP/64108             State:Idle            Presence:not_set         Watchers  5
64109@hints         : SIP/64109             State:Idle            Presence:not_set         Watchers  5
61064@hints         : SIP/61064             State:Idle            Presence:not_set         Watchers  3
64131@hints         : SIP/64131             State:Idle            Presence:not_set         Watchers  5
64130@hints         : SIP/64130             State:InUse           Presence:not_set         Watchers  5
68451@hints         : SIP/68451             State:Unavailable     Presence:not_set         Watchers  3
61057@hints         : SIP/61057             State:Idle            Presence:not_set         Watchers  1
61055@hints         : SIP/61055             State:Idle            Presence:not_set         Watchers  1
61051@hints         : SIP/61051             State:Idle            Presence:not_set         Watchers  1
61050@hints         : SIP/61050             State:InUse           Presence:not_set         Watchers  2
64117@hints         : SIP/64117             State:Idle            Presence:not_set         Watchers  5
64116@hints         : SIP/64116             State:Idle            Presence:not_set         Watchers  5
64115@hints         : SIP/64115             State:Idle            Presence:not_set         Watchers  5
61042@hints         : SIP/61042             State:Idle            Presence:not_set         Watchers  4
64114@hints         : SIP/64114             State:Idle            Presence:not_set         Watchers  5
64113@hints         : SIP/64113             State:Idle            Presence:not_set         Watchers  5
64112@hints         : SIP/64112             State:Idle            Presence:not_set         Watchers  5
64111@hints         : SIP/64111             State:Idle            Presence:not_set         Watchers  5
64110@hints         : SIP/64110             State:Idle            Presence:not_set         Watchers  5
62111@hints         : SIP/62111             State:Idle            Presence:not_set         Watchers  3
62110@hints         : SIP/62110             State:Idle            Presence:not_set         Watchers  3
64119@hints         : SIP/64119             State:Idle            Presence:not_set         Watchers  5
64118@hints         : SIP/64118             State:InUse           Presence:not_set         Watchers  5
62113@hints         : SIP/62113             State:Idle            Presence:not_set         Watchers  3
62112@hints         : SIP/62112             State:Idle            Presence:not_set         Watchers  3
10004@hints         : Custom:10004@hints    State:Idle            Presence:not_set         Watchers  9
10005@hints         : Custom:10005@hints    State:Idle            Presence:not_set         Watchers  9
10006@hints         : Custom:10006@hints    State:Ringing         Presence:not_set         Watchers 12
10007@hints         : Custom:10007@hints    State:Idle            Presence:not_set         Watchers 12
10000@hints         : Custom:10000@hints    State:Idle            Presence:not_set         Watchers 12
10001@hints         : Custom:10001@hints    State:Idle            Presence:not_set         Watchers 12
10002@hints         : Custom:10002@hints    State:Idle            Presence:not_set         Watchers 12
10003@hints         : Custom:10003@hints    State:Idle            Presence:not_set         Watchers  9
10008@hints         : Custom:10008@hints    State:Idle            Presence:not_set         Watchers 12
10009@hints         : Custom:10009@hints    State:Idle            Presence:not_set         Watchers 14
----------------
- 151 hints registered

Hey @mkozusnik Thanks for your response.

There is just little problem. Against your 151 hints. I have 5491 hints registered.

It just starts to show impact after it sort of crosses 3000+

i am however trying to see if there way to check limit using sql.

Below is just rough idea, I assume BLF request still go through dialplan, if so…

exten => s,n,( we receive subscribe event)
exten => s,n,MYSQL(query resultid ${numberofwatchers} Select ${watchers} from whatever table where pref_uid=’${ARG1}’)
exten => s,n,GotoIf(${watchers} => ‘3’?ExitBLFadd)

BLF requests do not go through the dialplan like that, and the number of watchers is not stored in a database.

Aha… That’ answers my questions. Thanks @jcolp

Is there some detail on how BLF requests go through and I can possibly dig something further ? I tried to search through internet but not much luck so far.

They are handled within the chan_sip module itself. There’s no real documentation of how to modify or alter it.

I didn’t realize you had so many. In that case, check the I/O on the network card. Sounds like you have quite a few devices connected. You may even want to consider setting up another server and migrate some of those devices to it. I set a soft limit of 400 devices to each server. The servers are trunked to each other and share a database (though DUNDi should also work) so I can pass calls between trunks. However, I don’t think the subscriptions can be shared across servers outside of some other mechanism.