Skip to content

Commit 833a95d

Browse files
committed
Make corrections in ARI REST over Websocket
1 parent e84482e commit 833a95d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

docs/Configuration/Interfaces/Asterisk-REST-Interface-ARI/ARI-REST-over-WebSocket.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# ARI REST over Websocket - DRAFT
1+
# ARI REST over Websocket
22

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.
44

55
## The Protocol
66

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).
88

99
### Request/Response
1010

@@ -72,12 +72,7 @@ Server responds with:
7272
"status_code": 200,
7373
"reason_phrase": "OK",
7474
"uri": "channels/ast-1741988825.0",
75-
"headers": [
76-
{
77-
"name": "Content-type",
78-
"value": "application/json"
79-
}
80-
],
75+
"content_type": "application/json",
8176
"message_body": "{\"id\":\"ast-1741990187.0\",\"name\":\"PJSIP/1171-00000000\",
8277
\"state\":\"Up\",\"protocol_id\":\"tqOjze4LWAiFZVNlsj4FJpE7H0VX1Yhm\",\"caller\":
8378
{\"name\": \"Alice Cooper\",\"number\":\"1171\"},\"connected\":{\"name\":\"\",
@@ -118,10 +113,10 @@ This requires us to send parameters to the resource. There are 4 methods for doi
118113
"method": "POST",
119114
"uri": "channels/ast-12345678.0/snoop/snoop-channel1",
120115
"query_strings": [
121-
"spy": "both",
122-
"whisper": "none",
123-
"app": "Record",
124-
"appArgs": "myfile.wav,5,60,q"
116+
{ "name": "spy", "value": "both" },
117+
{ "name": "whisper", "value": "none" },
118+
{ "name": "app", "value": "Record" },
119+
{ "name": "appArgs", "value": "myfile.wav,5,60,q" }
125120
]
126121
}
127122
```
@@ -155,7 +150,7 @@ This requires us to send parameters to the resource. There are 4 methods for doi
155150
```
156151

157152
/// 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.
159154
///
160155

161156
Server responds with:
@@ -176,6 +171,10 @@ Server responds with:
176171

177172
That's all there is to it.
178173

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.
180179

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

Comments
 (0)