Asterisk websocket incoming call - websocket

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?

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.

Related

How to send spring-graphql client subscription ping messages

I'm using the spring framework's spring-graphql library to create a graphql client, as per the docs. When connecting to the server using a websocket for subscriptions, everything works fine for 5 minutes but then the websocket times out and disconnects. It turns out the server requires the client to send a ping message to keep the websocket alive. This is a graphql ping message as specified in the graphql-ws protocol
I've checked in the docs and had a dig around in the code but can't see any way to send this ping message via the spring graphql client. Apollo client has similar functionality to what I'm after via a "keepalive" option in the graplq-ws ClientOptions. Is there any equivalent I can use via spring or alternative way to solve this?
I couldn't find any way to do this so raised an issue on github, and subsequently a PR with some changes to add basic support for sending pings.
See https://github.com/spring-projects/spring-graphql/pull/608
and https://github.com/spring-projects/spring-graphql/issues/605

Oryx CycloneTCP WebSocket Support for HTTP Server

I've started to evaluate Oryx Embedded CycloneTCP library, and able to run HTTP server / DHCP client with CubeMX config tools and STM32CubeIDE for custom STM32H7 board.
However, I did not get how to configure WebSocket support for HTTP Server. So I need some help / sample / demo code for it.
Its an a bit older question, but nonetheless...
https://gricad-gitlab.univ-grenoble-alpes.fr/Projets-INFO4/20-21/05/STM32F7_CycloneServer
shows how to implement a simple websocket->CAN Bus gateway.
Take a look at CycloneServer/Core/Src/main.c
In httpServerRequestCallback() the http connection gets upgraded to a websocket connection.
Received frames are processed in a seperate task (clientTask()).
sendCANBusToClient() shows how to send messages to connected websockets.

Xterm.js and websockets

I have a c++ server that use libssh to create a Linux shell. I send Linux commands from a javascript client application in a browser for example 'ls' or 'pwd' ecc ecc. to the c++ server by websockets, then I write the command in the libssh buffer followed by /n and a thread get the replay. I write the replay in a Json structure and by websockets again send it to the web client. Then I show the replay in a textarea and if the replay is plain ascii all is ok. Obviously replays to commands like nano doesn't work. So I would like javascript terminal emulators like Xterm. But every example connect it to socket.io or node.pty. I tried to use directly write but nothing is showed. How it's possible to connect Xterm.js to websockets or visualize a generic string?
xterm.js provides an 'addOn' that makes connecting to a websocket very easy. There is a very simplified example on this page that can help get you started, I believe.
https://xtermjs.org/docs/api/addons/attach/

Howto make SimpleWebRTC Directly Connect to my Websocket URL

By default, SimpleWebRTC uses https://sandbox.simplewebrtc.com:443/ as its signaling server. Now, this is an XHR endpoint, and somehow, signal master seems to switch it to a web socket connection.
Now, I’m trying to use my own signaling server with SimpleWebRTC. And it’s a straightforward websocket endpoint. So when creating the SimpleWebRTC object, I have SimpleWebRTC { “url” : ”ws://<my-IP>/chatroom" ...}
But upon creating the SimpleWebRTC object, it proceeds to try and connect to a different URI: http://my-IP/socket.io/?EIO=3&transport=polling&t=1450985796761-0.
How can I get SimpleWebRTC to just connect directly to ws://my-IP/chatroom, and have those parameters just passed along to other peers as signal master does? Does my signaling server have to do anything other than pass along the parameters / message that the initiator sends?
SimpleWebRTC uses socket.io instead of raw websockets. If you want to use raw websockets you can try replacing https://github.com/andyet/SimpleWebRTC/blob/master/socketioconnection.js with your raw websocket connection.
Or you implement the socket.io protocol in your server.
Here is signal master for your question:
github signalmaster
For run it, you must to install module of npm in server.js file.
Replace:
https://sandbox.simplewebrtc.com:443/
↓
http://<yourip>:8888/
But I don't understand, if we using that signal server, can we increase performance of frame rate and speed, and no need stun and turn server of google? When I deployed that signalserver on my cloud host? BTW, I can't understand when reading config for install turnserver on github.

Real-time HTTP stream writing console

Is there a program available that will allow me to interactively write HTTP stream data and send it to a server? Ideally I'm looking for a console app that will allow me to type or paste HTTP headers and body, send it to my server, and get the response headers and body back.
Does such a program already exist?
I'm running W7 64-bit with .NET 4.0.
if you change your mind and want a GUI app
http://code.google.com/p/rest-client/
or you can also use fiddler
Edit:
http://code.google.com/p/rest-client/ also supports commandline
Maybe telnet is an option for you? If it's not already installed on your machine, take a look at this guide from MS.
To connect to your server use it like this:
telnet www.myserver.de 80
After the connection is established, you can paste your HTTP GET reqests or what ever you like.
tinyget is a useful MSFT tool that will make simple get requests. You can store these requests in text files and stream them in.

Resources