2

I want to show all incoming call in a web page using websocket.

I've followed asterisk official documentation for getting started ari The example provided works fine using connection:

$ wscat -c "ws://localhost:8088/ari/events?api_key=asterisk:asterisk&app=hello-world"

But when I try to connect to channels instead I receve an error:

$ wscat -c "ws://localhost:8088/ari/channels?api_key=asterisk:asterisk"
error: Error: unexpected server response (200)

I have also tried to use PHP ARI Channel List and it's works fine. What am I doing wrong?

  • Where is programming question here? Enable asterisk debug mode and see error or inspect source code of asterisk(it is open and free) – arheops Dec 22 '15 at 16:36
  • I'm confused. Didn't exists a websocket for receving incoming call? I don't want use long-polling for checking it –  Dec 22 '15 at 17:54
  • Please read guidlines. You should show your effort to do something, here i see no any programming question. "Please help me find manual" is not programming question. – arheops Dec 22 '15 at 20:43
  • 4
    I'll try to search more. By the way your behaviour is not constructive. I'm searching without find, so I ask for some help. –  Dec 22 '15 at 21:08

1 Answers1

1

You only connect a WebSocket to the events resource. That creates your pipe of events from Asterisk to your remote ARI application. You would not use the WebSocket protocol (ws) for any other resources in Asterisk.

The other resources are standard REST(ful) HTTP resources. You use those to control Asterisk resources in your application - such as channels, bridges, etc.

You may want to look at the ARI Hello World documentation on the Asterisk wiki for an example of using a WebSocket for events/HTTP for control.

Matt Jordan
  • 2,899
  • 1
  • 27
  • 29
  • thank you, very exhaustive . This means that I'm forced to use polling to catch incoming calls? –  Dec 22 '15 at 22:36
  • 1
    Nope. With ARI, you send the call into the Stasis dialplan application. That pass control to your remote app. You'll receive a notification asynchronously over the websocket that you have a channel in your control. – Matt Jordan Dec 23 '15 at 02:12
  • Thanks! I'm at a good point now. But there is a way to add extension for send all incoming call into my dialplan application? –  Dec 23 '15 at 08:33
  • 1
    You wouldn't do that through an API. That is one part that is still configured in extensions.conf. The Hello World documentation shows that here - https://wiki.asterisk.org/wiki/display/AST/Getting+Started+with+ARI#GettingStartedwithARI-ConfiguringAsterisk . If you wanted to send all calls there, you'd use a pattern match like exten => _X.,1,NoOp ... – Matt Jordan Dec 24 '15 at 01:25
  • It's works, thanks but I have issues. My conf is: exten => _X.,1,NoOp() same => n,Stasis(test). When I try call another number nothing happens.. no events from WS. When I stop call StasisEnd event will released.. –  Dec 24 '15 at 17:01
  • I think you're at the point where you really need to read the documentation on what you're trying to use. Start with the top of the ARI documentation, and read how to manipulate channels after that. – Matt Jordan Dec 24 '15 at 18:54