PJSIP Setting to allow one call at a time

Hi Guys,

I am working on moving from SIP to PJSIP.
I can now attach multiple endpoints to a single extension/user.
For example Extension 100 is attached to devA, devB.

If one device is busy and the extension is called again, the other device will still ring but the user with extension 100 is already busy. Which setting do I need to set to allow only one call at a time ?

Like 101 calls 100, 100 picks up devA.
102 then calls 100, 102 get’s busy signal because 100 already picked up one of his/her endpoints.

There is no setting or functionality built in for this, instead the tools are provided to implement such a thing if you want using the GROUP dialplan functions[1][2].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Function_GROUP
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Function_GROUP_COUNT

2 Likes

Hi Jcolp, thank you for the reply ! Do you maybe have a working example ?

I don’t have any examples handy. They’re dialplan functions though so you get/set them the same way as any other one.

Maybe this snippet will help:

[from-outside]
...
; Call Management
 same =>     n,Set(GROUP()=incoming)
 same =>     n,Verbose(2,(ibg) GROUP COUNT incoming: ${GROUP_COUNT(incoming)})
 same =>     n,GotoIf($[ "${GROUP_COUNT(incoming)}" > "${GLOBAL(MAX_INCOMING)}" ]?busy)
 same =>      n,Dial(${DIALGROUP},${CALLTIMEOUT})
; Give some hints in case nobody answers
 same =>      n,Answer()
 same =>      n,...
 same =>      n,Hangup()
; Signal busy, if necessary and possible
 same =>     n(busy),Verbose(1,(ibg) Signalling busy condition (max(incoming)=${GLOBAL(MAX_INCOMING)}, count=${GROUP_COUNT(incoming)}))
 same =>     n,Set(CDR(userfield)=BUSY signalled)
 same =>     n,Set(DIALSTATUS=BUSY)
 same =>     n,Busy()
 same =>     n,Hangup()

Here call management happens only for incoming lines. It’s up to you what you want to count. Setting the GROUP() increments internally a counter for this group. The count can later be used for various purposes. In this case for manually signalling a busy condition.

Caveat emptor: There is no guarantee that a caller ends up hearing the busy tone. If the available lines are exhausted, the telco takes care of the rejection.

Alright, thanks for the information !

What eventually helped me is :

    ...
    same => n,NoOp(PJSIP/${DEST} has status 1 : ${DEVICE_STATE(PJSIP/${DEST} )})
    same => n,GotoIf($[ "${DEVICE_STATE(PJSIP/${EXTEN})}" = "BUSY" ]?DevBus:DevAva)
    same => n(DevAva),Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})})
    same => n(blocked),Hangup()
    same => n,Answer()
    same => n(DevBus),Playtones(busy)
    same => n,Busy(10)
    same => n,Hangup()
    ...

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.