Websockets
Pushing data using the WebSocket interface
Warp 10 offers an alternative to the standard POST interface for pushing data.
This alternate write path is based on HTML5 WebSockets.
The WebSocket endpoint is ws(s)://API_ENDPOINT/api/v0/streamupdate
, where API_ENDPOINT
is a valid endpoint.
The WebSocket interface supports individual messages of up to 1000000 bytes. Each message is transmitted in a dedicated WebSocket frame.
Valid WebSocket messages
Token specification | TOKEN <token> | This message sets the current write token for the WebSocket connection. |
Token reset | CLEARTOKEN | This message resets the current write token. Any data update attempt will fail until TOKEN <token> is called first. |
No Operation | NOOP | This message does nothing apart from keeping the connection alive. |
Error handling | ONERROR MESSAGE / CLOSE | Sets the error handling mode. If 'MESSAGE' is specified, errors will generate a WebSocket message of the format ERROR message but will leave the connection open. If 'CLOSE' is specified, errors will throw an exception and will close the connection. The default error handling mode is 'CLOSE'. |
Data update | TS/LAT:LON/ELEV class{labels} VALUE | This message pushes the given data using the current write token. The format of this message is the GTS input format. |
Responses
After successful execution of one of the messages above, a response message with the following syntax is sent:
OK <seqno> ...
Depending on the error handling mode set via ONERROR
, a failed operation will either lead to an ERROR ...
message or to an exception which will close the WebSocket.
Plasma
Plasma is used to stream datapoints which are inserted or updated in Warp 10.
The WebSocket endpoint is ws(s)://API_ENDPOINT/api/v0/plasma
, where API_ENDPOINT
is a valid endpoint.
Valid WebSocket messages
The message to send is: SUBSCRIBE <Read token> <Selector>
, for example:
SUBSCRIBE _RQWearwByX.xxx.ck0vYCf_F ~.*{}
Responses
The response follows the GTS input format:
1380475081000000// foo{label0=val0,label1=val1} 123
Mobius
This endpoint is used to stream periodically the result of a WarpScript execution.
The WebSocket endpoint is ws(s)://API_ENDPOINT/api/v0/mobius
, where API_ENDPOINT
is a valid endpoint.
Valid WebSocket messages
<% macro %> <interval> EVERY
For example, to Fetch the last 5 values every 10 seconds:
<% [ '_RQWearwByX.xxx.ck0vYCf_F' '~.*' {} NOW -5 ] FETCH %> 10000 EVERY
See EVERY.
Responses
The response follows the JSON result form of a WarpScript execution:
["foobar",2.718281828459045,3.141592653589793,42]