Stream Device Data with a WebSocket (Use Case)
In this example, we will discuss the Juniper Mist use case of streaming device data with a WebSocket.
A WebSocket is a protocol that provides full-duplex communication over a TCP connection. A WebSocket API provides a way for a client to communicate with an endpoint. Juniper Mist uses this protocol to stream near-real-time data to a client. A client will make a request for the data it wants to receive by subscribing to a channel. The client makes the request only once, and the server will stream the channel data to the client as updates are made.
This method of communication is good for receiving event-driven data in near–real time. Its primary use is for collecting device data. You and other network administrators can then feed this data into a custom event display, a notification system, an external logging facility, and much more.
Using WebSocket is especially helpful if the information that your organization needs isn’t available natively within the Juniper Mist portal.
In this use case, we show how to configure a client to request and subscribe to a site’s device statistics.
Using a WebSocket requires the following elements:
-
Authentication
-
HTTP header configuration
-
WebSocket Connection URL (wss://api-ws.mist.com/api-ws/v1/stream). Please verify your URL based on your geographical location.
Communicate with a MIST WebSocket Endpoint
To communicate with the Juniper Mist WebSocket endpoint, you use an application called Postman. Postman is a GUI API platform for building and using APIs. You can build scripts that make multiple API calls. This API also enables you to make WebSocket calls.
The following steps describe how you can connect to the Juniper Mist WebSocket, starting with adding the URL to the input box next to the Connect button: