You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Configuration/Interfaces/Asterisk-REST-Interface-ARI/ARI-REST-over-WebSocket.md
+15-16
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# ARI REST over Websocket - DRAFT
1
+
# ARI REST over Websocket
2
2
3
-
Historically, using ARI required two communications channels... HTTP for making REST requests and getting their reponses, and Websocket for receiving events. Upcoming releases of Asterisk however, will allow you to make REST requests and receive their responses over the same Websocket you use to receive events.
3
+
Historically, using ARI required two communications channels, HTTP for making REST requests and getting their responses, and a Websocket for receiving events. Upcoming releases of Asterisk however, will allow you to make REST requests and receive their responses over the same Websocket you use to receive events.
4
4
5
5
## The Protocol
6
6
7
-
There are several published protocols for request/response type communication over Websockets including [WAMP](https://wamp-proto.org), [JSON-RPC](https://www.jsonrpc.org), [XMPP](https://xmpp.org), [Socket.IO](https://socket.io), etc. but these are all fairly heavyweight and would require significant effort to implement. Instead we went with a simple JSON wrapper loosely based on[SwaggerSocket](https://github.com/swagger-api/swagger-socket).
7
+
There are several published protocols for request/response type communication over Websockets including [WAMP](https://wamp-proto.org), [JSON-RPC](https://www.jsonrpc.org), [XMPP](https://xmpp.org), [Socket.IO](https://socket.io), etc. but these are all fairly heavyweight and would require significant effort to implement in Asterisk. Instead we went with a simple JSON wrapper inspired by[SwaggerSocket](https://github.com/swagger-api/swagger-socket).
@@ -155,7 +150,7 @@ This requires us to send parameters to the resource. There are 4 methods for doi
155
150
```
156
151
157
152
/// warning
158
-
PICK A METHOD! Using more than one method to pass parameters to the resource is highly discouraged because the rules for duplicates are a bit tricky. Of the first 3 methods, the first occurence wins. However, if you also use the 4th method, it will overwrite any earlier values.
153
+
PICK A METHOD! Using more than one method to pass parameters to the resource is highly discouraged because the rules for duplicates are a bit tricky. Of the first 3 methods, the first occurrence wins. However, if you also use the 4th method, it will overwrite any earlier values.
159
154
///
160
155
161
156
Server responds with:
@@ -176,6 +171,10 @@ Server responds with:
176
171
177
172
That's all there is to it.
178
173
179
-
## Caveats
174
+
## Restrictions
175
+
176
+
There are two:
177
+
178
+
* You can't get binary data like recordings via the websocket. The frames written to the underlying websocket use the TEXT opcode and the messages are all JSON and while there are ways we could send binary data, they're just too complicated and could interfere with getting asynchronous events. Attempting to retrieve binary data will result in a 406 "Not Acceptable. Use HTTP GET" response.
180
179
181
-
There's really only one... You can't get binary data like recordings via the websocket. The frames written to the underlying websocket use the TEXT opcode and the messages are all JSON and while there are ways we could send binary data, they're just too complicated and could interfere with getting asynchronous events. Attempting to retrieve binary data will result in a 406 "Not Acceptable. Use HTTP GET" response.
180
+
* Calling `GET` on `events` via HTTP is what does the `UPGRADE`to a websocket so it doesn't make sense to call it _via_ the websocket. If you try, you'll get a 400 "Bad request. Can't upgrade to a websocket from a websocket".
0 commit comments