WebSocket Protocol Guide

Use this guide when long-lived WebSocket sessions, message matching, or realtime channels need to be part of a performance or transaction test.

What this page helps you do

What this page helps you do

Use this guide when long-lived WebSocket sessions, message matching, or realtime channels need to be part of a performance or transaction test.

Who this is for

Teams deciding how a protocol or browser runtime should fit inside one transaction-aware scenario.

Prerequisites

  • A transport or browser flow that already matters to the workload

By the end

A clearer protocol-specific path that still fits the same scenario and reporting model.

Use this page when

Use this page when WebSocket Protocol Guide belongs inside the transaction story and you need the supported path into the same scenario model.

Visual guide

Transaction diagram showing source action, handoff, downstream processing, and completion.
The settings on this page only make sense when the workflow is treated as one transaction from source action to downstream completion.

Guide

What This Guide Covers

Use this guide when a WebSocket connection is the source, destination, or observed channel in the workflow. LoadStrike supports ws:// and wss:// endpoint configuration, subprotocols, headers, connect and close timeouts, text and binary message specifications, expected-message matching, reconnect policy, message latency, throughput, and byte metrics where supported by the SDK.

Long-Lived Sessions

WebSocket scenarios often care about more than one request. Model the connect, send, receive, and close behavior explicitly so reports can show message latency, connection duration, reconnects, receive timeouts, and protocol failures beside normal scenario counts.

Exact SDK Support

C#, Java, Python, TypeScript, JavaScript, and Go support native or delegate-backed Produce and Consume. Python native use requires the websocket install extra, and TypeScript or JavaScript native use runs on Node.js. A matching delegate takes precedence over NativeClient.

Native Limits And Compatibility

Native Consume uses JSON tracking because WebSocket frames do not include application message headers. Java limits a fully reassembled inbound text or binary message to 1 MiB. Java TrackPingPong, TrackCloseCodes, and TrackMessageLatency are deprecated compatibility fields with no effect.

Plan Gate

WebSocket endpoint support is available on Pro and above. Runs still validate any extra features used by the scenario, such as portal reporting, sinks, thresholds, or distributed cluster settings.

Protocol setup samples

Use these samples for native or delegate-backed WebSocket Produce and Consume in C#, Java, Python, TypeScript, JavaScript, and Go. A matching mode delegate takes precedence over NativeClient. Python native WebSocket use requires the websocket extra.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

WebSocket Protocol Setup

using LoadStrike;
using LoadStrike.CrossPlatform;
using LoadStrike.CrossPlatform.WebSockets;

// NativeClient is available for C# Produce and Consume endpoints.
var endpoint = new WebSocketEndpointDefinition
{
    Name = "orders-websocket",
    Mode = TrafficEndpointMode.Produce,
    TrackingField = TrackingFieldSelector.Parse("header:x-tracking-id"),
    Url = "wss://realtime.example.com/orders",
    Subprotocols = ["orders.v1"],
    MessageHeaders = new Dictionary<string, string>
    {
        ["x-tracking-id"] = "ord-1001"
    },
    NativeClient = new WebSocketNativeClientOptions
    {
        Messages =
        [
            WebSocketMessageSpec.Text("{\"type\":\"subscribe\",\"orderId\":\"ord-1001\"}")
        ],
        ExpectedMessages =
        [
            new WebSocketExpectedMessage
            {
                ContainsText = "ord-1001",
                Timeout = TimeSpan.FromSeconds(10)
            }
        ]
    }
};

_ = endpoint;

Goal

Connection URL

Use an absolute ws:// or wss:// endpoint for the realtime channel under test.

Message matching

Keep a stable tracking value in text, binary, header, or JSON payload data so LoadStrike can match the workflow.

Java inbound limit

Java limits each fully reassembled inbound text or binary message to 1 MiB. Its deprecated TrackPingPong, TrackCloseCodes, and TrackMessageLatency compatibility fields have no effect and add no metrics.

Mode boundary

This C# sample uses native Produce. Every supported SDK can use native or delegate-backed Produce and Consume; a matching delegate owns execution. Go names those fields Produce and Consume, while async-named SDKs expose ProduceAsync and ConsumeAsync.