I have a dial plan and an AGI script to initiate two calls from my sip client by calling *1337 and then give the two numbers I want to call like this NUMBER1#NUMBER2#. The point is that I want to call two numbers at the same time and bridge them into a conference room where I am already waiting, to have a three-way call from the beginning (without the need to have the first person wait for me to call the other one).
The whole thing works really well, except that I have two major problems.
- The calls are originated but I think that they are originated sequencially (and not at the same time).
- One of the 2 branches drops after a few seconds.
The calls are both to land-lines, or mobile phones. Not to other extensions whatsoever. And we all three are able to talk to each other so there is no codec issue. The asterisk logs do not show anything helpful, just that one branch hangs up. It takes a few seconds until the hang up, until then we all communicate just fine.
Also, I have other extensions that allow me to just call a number and talk with the other party and it works really well, so NAT/Firewalling is not a problem either.
Is there any possible way to do it?
My dialplan:
[from-custom-internal]
exten => *1337,1,Goto(from-internal-service,*1337,1)
[outbound]
exten => s,1,NoOp(Outgoing call processing)
same => n,Dial(PJSIP/${CALLERID(dnid)}@OUTBOUND_Direct_Out)
same => n,Hangup()
[from-internal-service]
exten => conf,1,NoOp()
same => n,Verbose(CONFID is: ${CONFID})
same => n,ConfBridge(${CONFID},default_bridgez,default_userz)
exten => *1337,1,Answer()
same => n,Wait(1)
same => n,Playback(beep)
same => n,Read(first_number,,60,,60,#)
same => n,Wait(1)
same => n,Playback(beep)
same => n,Read(second_number,,60,,60,#)
same => n,Set(CONFID=${EPOCH})
same => n,AGI(/var/lib/asterisk/agi-bin/internal_service_script.py,${CONFID},${first_number},${second_number})
same => n,ConfBridge(${CONFID})
same => n,Hangup()
My AGI script:
#!/usr/bin/python
import sys
from asterisk.ami import AMIClient, SimpleAction
def make_call(conf_id, number_to_call):
client = AMIClient(address='127.0.0.1', port=5038)
client.login(username='USERNAME_HERE', secret='PASSWORD_HERE')
action = SimpleAction(
'Originate',
Channel='PJSIP/{}@OUTBOUND_Direct_Out'.format(number_to_call),
Context='from-internal-service',
Exten='conf',
Priority=1,
Variable='CONFID={}'.format(conf_id)
)
client.send_action(action)
client.logoff()
if __name__ == '__main__':
conf_id, first_number, second_number = sys.argv[1:4]
make_call(conf_id, first_number)
make_call(conf_id, second_number)