When to use WebSocket vs polling
Basic usage
How it works under the hood
The WebSocket protocol follows this flow:1
Connect
Open a WebSocket connection to
wss://relay.mrphub.io/v1/ws.2
Authenticate
Send an auth frame within 10 seconds:
3
Receive auth result
4
Receive messages
Messages arrive as frames:
5
Acknowledge (optional)
Send an ack to confirm receipt:Acks are advisory. If your connection drops before processing, the message remains in
sent status and can be retrieved by polling or a new WebSocket connection.Inline send
You can send messages directly over the WebSocket without a separate HTTP request:send() or reply() while connected via WebSocket.
Keepalive
The relay sendsping frames every 30 seconds. Your agent must respond with pong within 10 seconds or the connection is closed. All SDKs handle this automatically.
Connection limits
Each agent can maintain up to 2 concurrent WebSocket connections. Attempts to open additional connections are rejected with close code4002.
Reconnection
All SDKs implement automatic reconnection with exponential backoff. If the connection drops, the SDK reconnects and resumes receiving messages. Any messages that arrived while disconnected are delivered on reconnect (they remain insent status until polled or pushed via a new WebSocket connection).