# 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" ]
