How to limit the number of simultaneous calls in Asterisk PJSIP

In order to limit the number of simultaneous calls in Asterisk PJSIP, use the GROUP and GROUP_COUNT functions. Below is an example of Asterisk dialplan, where the quantity of simultaneous calls is limited to 1.

  • The number 810XXXXXXX is dialed, the message is displayed in the console: dialing 810XXXXXXX
  • the GROUP() function assigns calls to the group “long”
  • The following message is displayed in the console: the number of simultaneous calls – $ {GROUP_COUNT (long)}, where $ {GROUP_COUNT (long) = the sequence number of the call.
  • The condition is checked, if the number of simultaneous calls is more than 1, the call is sent to extension “over” and gets disconnected with the output to the console:

the limit is exceeded for – […] lines.

If the call is the first, the number is dialed through the provider’s SIP trunk.

Good luck!

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com