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, ping/pong tracking, close-code tracking, message latency, throughput, and byte metrics where supported by the SDK runtime.

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.

Native Or Delegate-Backed

Use native WebSocket options when the SDK can own the socket flow directly. Use delegate-backed endpoints when the application client, authentication flow, or message codec already exists in your test project. Both options stay inside the same LoadStrike runner, portal, local report, and sink lifecycle.

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 to compare native and delegate-backed WebSocket endpoint setup across the supported SDKs.

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;

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.

Connection metrics

Track receive latency, reconnect behavior, close codes, and message volume alongside scenario results.