0


I'm writing simple popup application integrated with Asterisk server. Our test environment is based on FreePBX where we've configured a few SIP trunks. The test is between two extensions 3000 and 3001.

3000, 3001 and other extensions are controlled by SIP client (microsip) for test purposes, later they may become some other sip clients or softphones.

What I need is once someone calls extension 3000, an operator was able to answer the call using regular SIP client, while my application would show some information about the call. I was able to achieve that using AMI. Now I want a button in my application that would allow me to put the call on Hold. I know, that AMI doesn't expose such feature, so I'm trying to use Async AGI. (btw I'm using asternet to communicate with asterisk)

AgiAction agi = new AgiAction(channel, "MusicOnHold");
ManagerResponse resp = manager.SendAction(agi);

Once I've done that I've got a reply

Failed to add AGI command to channel SIP/3000-00000003 queue

I wonder what that means?

Also I've been trying to start "MusicOnHold" command via CLI, and I've got a response

Channel XXXXX is not controlled by AGI"

I did try to add something like that into the dialplan (extensions.conf):

[default]
exten => 3000,1,NoOp(Async AGI)
same => n,AGI(agi:async)

that would remove "Channel XXXXX is not controlled by AGI" error, but still leave the "Failed to add AGI command to channel SIP/3000-00000003 queue" error. And what is worst, once I've got this dial plan, my sip client stopped receiving calls, though AMI was still able to capture that.

I wonder what is correct way to achieve what I want? I'm completely new to asterisk, and maybe I'm missing basic concepts, so I would really appreciate good example. Thank you.

miken32
  • 42,008
  • 16
  • 111
  • 154
Georgy Smirnov
  • 391
  • 3
  • 10

1 Answers1

0

Async agi is way for channel be controlled via AMI requests, not AGI.

I am unsure what do asternet code you send, consult asternet documentation

Also note, you have no way put on hold call which already in asyncagi(already onhold!!!),unless you stopped hold by some other action

arheops
  • 15,544
  • 1
  • 21
  • 27
  • Thank you for reply, the asternet code executes AGI command (according to asterisk documentation "Add an AGI command to execute by Async AGI"). So basically I'm correct, that when I control a call via AMI, I may execute some Async AGI command, on that call, and for example put the call on hold, or consulting transfer? – Georgy Smirnov Mar 11 '15 at 07:40
  • AsyncAGI call do put call on hold when you issue that in dialplan. No way put it on hold AGAIN. If you have no hold, check your musiconhold class(or set that before AsynAGI), check it have files and working ok. – arheops Mar 11 '15 at 09:35
  • I see, so in fact, to make AsyncAGI calls I first need to alter dialplan, so that the call gets into that AsyncAGI mode, I believe then that AsyncAGI is no help for me here. I wonder, when programming for Avaya, Cisco, Lync etc there's always a concrete API to have full control over the call (3rd party call control/TSAPI/TAPI/Finesse), isn't there anything like that for Asterisk? – Georgy Smirnov Mar 11 '15 at 10:48
  • There is TAPI realization for asterisk. However asterisk give much more control then cisco,avaya, Lync etc. Sure you need read some books. Or hire someone to emulate for you api you know for asterisk. Asterisk AGI is almost same with cisco tcl script, if you use it correctly. – arheops Mar 11 '15 at 14:03