Skip to main content
Crawlstack allows you to capture live data streams from modern real-time applications by intercepting WebSocket traffic and Server-Sent Events (SSE).

WebSocket Interception

To capture WebSocket messages, you must first enable interception. You can then retrieve messages using runner.getWebsocketMessages().

Event Object

Server-Sent Events (SSE)

Similarly, you can enable SSE interception and poll for messages.

Event Object

Best Practices

Real-time streams can be high-volume. To prevent memory issues or database spam:
  1. Filter early: Only process or publish messages that contain the data you need.
  2. Handle state: Use a local variable in your script to accumulate data and only call publishItems once a specific condition is met or the run is about to finish.
  3. Wait for completion: Use runner.waitFor() to give the stream enough time to arrive before the script terminates.