WebSockets
ProtocolsDrive a persistent WebSocket connection: connect, send frames, await messages and assert on them — full-duplex load, not just request/response.
Browse all 52 demos 12 categories
No demos match.
$ loadr run examples/09-websocket.yaml
# WebSocket load: connect, exchange messages, assert on the conversation.
name: websocket
description: WS connect/send/receive with session limits
scenarios:
chat:
executor: constant-vus
vus: 20
duration: 2m
flow:
- request:
name: chat session
url: wss://chat.example.com/ws
protocol: ws
headers:
Origin: https://chat.example.com
ws:
subprotocols: [ "chat.v2" ]
send:
- '{"type":"hello","room":"load-${vu}"}'
- { text: '{"type":"message","body":"ping ${iteration}"}', delay: 500ms }
receive_count: 2
session_duration: 10s
checks:
- { type: body_contains, name: got ack, value: '"type":"ack"' }
- think_time: { type: constant, duration: 1s }
thresholds:
ws_session_duration: [ "p(95)<11000" ]
ws_msgs_received: [ "count>100" ]View raw: examples/09-websocket.yaml
What it shows
- ▸Persistent full-duplex connection
- ▸Send / receive frame steps
- ▸Assertions on messages