Skip to content
Swarmetry

Build scenarios

gRPC over TLS, WebSocket listening and SSE streams

TLS certificates and connection options of gRPC, binary data, pings and listening on WebSocket, SSE streams that end.

Some services are not plain HTTP: gRPC behind TLS certificates, WebSocket feeds that push messages, Server-Sent Events. This page shows how to test them from the workflow editor.

gRPC: TLS certificates and connection options

Open a gRPC step: the Connection section holds the options used when the virtual user connects.

gRPC connection

  • TLS certificates are secrets of the project holding PEM text, the text that starts with -----BEGIN CERTIFICATE----- (or -----BEGIN PRIVATE KEY----- for a key) your team gives you; add them in the secrets screen first. Choose the Certificate authority (CA) that signed the server's certificate when it is not a public one. For mutual TLS, choose a Client certificate and its Client key: they go together, and the editor says so at once if one is missing. A Key password only decrypts an old encrypted PEM key.
  • TLS settings and Plain text exclude each other: choosing a certificate turns plain text off.
  • Authority sends another host name to the server (behind a proxy, for example). It cannot hold a secret.
  • Largest message received / sent raise the limits of gRPC (4 MB received by default; 0 keeps the default).
  • Reflection metadata are headers sent with the reflection requests (the requests that ask the server to describe its services), when the server needs a token for them; they may use secrets.
  • Connection timeout bounds the connection (1 minute by default).

Steps with different TLS settings never share a connection, even to the same server.

When a test starts, Swarmetry checks the gRPC targets written in the scenario (host:port) like the hosts of web requests: a host that is not one of the project's sites to test is refused before anything runs.

WebSocket: binary data, pings and listening

A WebSocket step runs its actions in order. Besides sending text, receiving one message, waiting and closing:

  • Send binary data sends bytes written in base64 (for example AAEC/w==). Binary messages received are kept as base64 text, so checks and variables can read them.
  • Ping sends a ping; the answer feeds the ws_ping metric.
  • Listen to messages collects the messages received for a duration (5 seconds by default, never longer than the session timeout). It can stop earlier: after a number of messages (Stop after), or at the first message that contains, equals or matches a pattern (Stop at a message). Messages into keeps the list of messages, Count into their number.

WebSocket listen

Check the result with the variable checks: count is at least 3, messages contains "BTC".

SSE: streams that end

Swarmetry reads a Server-Sent Events stream until the server closes it. A stream that never ends stops at the step's timeout, and its events are lost: use a stream that ends, for example with a count parameter that closes it after a number of events. The SSE panel recalls it, and warns when no timeout is set.

Ask the assistant

The assistant knows worked examples of gRPC over TLS and of WebSocket listening. Ask it, for example: “call GetProduct on api.example.com:443 over TLS with the CA in the secret TARGET_TLS_CA” or “listen to three ticks of the ticker”.