Lifecycle Overview
Step 1: WebSocket Handshake
Initiate a secure WebSocket connection to the Rhombus endpoint with authentication headers:Step 2: STOMP CONNECT
After the WebSocket connection is established, send a STOMPCONNECT frame to initialize the messaging protocol:
CONNECT Frame
Expected Response: CONNECTED Frame
Building STOMP Frames
STOMP frames follow a simple text-based format:- Each frame starts with a command name
- Headers are key-value pairs separated by colons, one per line
- An empty line separates headers from the body
- The frame ends with a null byte (
\x00)
Step 3: Subscribe to a Topic
After the STOMP connection is established, subscribe to the organization change topic:SUBSCRIBE Frame
Replace
{orgUuid} with your organization’s UUID. Retrieve it via the REST API endpoint POST /api/org/getOrgV2.Step 4: Message Loop and Heartbeats
Once subscribed, your application enters a message loop where it:- Receives MESSAGE frames containing event data
- Sends heartbeats to keep the connection alive
- Receives heartbeats from the server
Heartbeat Mechanism
Heartbeats are single newline characters (\n) sent at the negotiated interval (10 seconds). Both the client and server send heartbeats. If either side stops receiving heartbeats, the connection is considered dead.
Parsing Incoming Frames
Message Loop
Step 5: Graceful Disconnection
Before closing the WebSocket, send a STOMPDISCONNECT frame: