Stream Packet Captures with a WebSocket (Use Case)
In this example, we discuss the Juniper Mist use case of streaming device packet captures with a WebSocket.
As described in Stream Device Data with a WebSocket (Use Case), the WebSocket API enables client communication with an endpoint. You can use this method of communication for situations where you want to receive near-real time, event-driven data without having to refresh the web browser.
This use case outlines how you can use a WebSocket to stream packet captures (PCAPs). PCAPs capture data packets as they traverse the network, and serve as a powerful troubleshooting tool to help debug traffic issues, as well as broader networking issues.
While you have the ability to download PCAPs from the Mist portal, PCAPs that occurred in the past might only be beneficial in some troubleshooting scenarios. Streaming PCAPs with a WebSocket, on the other hand, enables you to monitor and analyze packets as they traverse the network, in near-real time. With Juniper Mist, you can analyze PCAPs for wired, wireless, and WAN connections.
To establish client communication with an endpoint, two things must occur:
-
A client must subscribe to a channel in order to request the data it wants to receive.
-
Then, the server streams the channel data to the client as events occur.
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. See WebSocket API Endpoint.
When reusing code blocks, replace placeholder values with actual values, such as your API token, organization ID, site ID, AP name, and so on.
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 use Postman to carry out any API related tasks, including making WebSocket calls and streaming data.
For general information about getting started with Postman, see Use Postman to Make Your First API Call and Get Started in Postman.
To learn how to create a WebSocket request in Postman, see Create a WebSocket Request.
The following steps describe how you can connect to the Juniper Mist WebSocket: