Asterisk send data to Web application



Can I ask, I install virtual box and I want to install asterisk in virtual box can I also still run your program ?

Thank you in advance.



I got it work…thank you. I have question can I run this in virtual box your program ?I want to explore asterisk when I’m at home.

Thank you in advance


Everything except PCI and USB hardware will work in a virtual machine.

Whilst VM’s are more likely to suffer high jitter, if the host isn’t correctly configured that shouldn’t be a problem for your use.


Hi david551,

Thank you for the reply…

Everything except PCI and USB hardware will work in a virtual machine.

You mean I cannot use usb flash drive, keyboard (usb type) in virtual machine ?

suffer high jitter,

what is the context jitter mean ?

if the host isn’t correctly configured that shouldn’t be a problem for your use.

what is host you mean not properly configured ?

Thank you in advance.


It is possible that flash drives are handled specially, as they are well known devices. However the normal way I’ve seen that sort of thing handled is by remoting a block device from the controlling machine.

Jitter means variation in the inter-arrival time of voice frames. Ideally you want them to arrive at close to 20ms intervals, and certainly not in a big bunches at 100ms intervals.

Properly configured means dedicating enough CPU power and disk bandwith and guaranteeing that that power will be provided to the VM in milliseconds even if that is to the disadvantage of processing on another VM. Orignal VM designs would schedule VMs for quite long time slices, and manipulate the time they saw so as to make them think they were running continuously.


Sorry for the late reply. Yes you can use it on windows and Linux(if using GUI).


Thank you for the reply.



Can I ask how do you run this in live server forever php mysocket.php Newchannel ?

Also Im curious to know what is the purpose of this two lines why you have it there ?
fputs($socket, “Action: WaitEvent\r\n”);
fputs($socket, “Action: Logoff\r\n\r\n”);

Thank you in advance.


Wait for an event to occur.
This action will ellicit a Success response. Whenever a manager event is queued. Once WaitEvent has been called on an HTTP manager session, events will be generated and queued.

Logoff the current manager session.

Check the whole list of manager actions here


Hi @ambiorixg12 ,

Thank you for the reply.


Hi @ambiorixg12 ,

Can I ask something in “Newchannel” Event, how do I know the call is answered by agent ? is this determined by the “ChannelState” ?

Thank you in advance.


You should take a while to exercise your mind and do some quick reading and research, and you will learn a lot… all the information is on the Asterisk wiki

Dialing Offhook
Linkedid - Uniqueid of the oldest channel associated with this channel.


Hi, I am reading the links that you provided, but it did not help me.

in “ChannelStateDesc” which one that tells the agent answered or pick up the phone. because I have something to do when the agent answered the incoming calls.

I googled I found some answer they use “NewState”, I don’t know what the difference of newchannel and newstate.

Thank you in advance.


Both of those are documented on the wiki as @ambiorixg12 linked (at least for NewChannel).

NewChannel: Raised when a new channel is created.
NewState: Raised when a channel’s state changes.

Meaning NewChannel happens once when the channel is created, and NewState can happen a few times for a channel.



Thank for the reply…so I must look out for the event “NewChannel” ? …I tried to run the script of @ambiorixg12, but I only saw the events, Newexten,HangupRequest,Hangup,DeviceStateChange ,UserEvent,VarSet,SoftHangupRequest,ExtensionStatus. or maybe I miss some logs copying in cli to my notepad…can you tell me please which event that the agent will answer the phone or pick up…I am really confuse.

Thank you in advance.


I don’t use AMI and don’t know what the event flow would look like for such a scenario. If you’re going to write such a thing though you should look at the events which are produced, go read about them, and understand what is happening.


so what would you use ?..yeah I am reading those events. but I can’t get which event is fired when the agent answered the incoming call.

Thank you in advance


I’d still likely use AMI. How I’d go about it I don’t know as I haven’t done it.



Thank you for the quick reply. Ok I will read again the docs hope I can find answers.


@jcolp @ambiorixg12,

what is “up” mean in “ChannelStateDesc” in Event: Newchannel?

Thank you in advance