Next Practical Step
Install Plugins Manager, add a WebSocket plugin matching your JMeter version, and prove open-write-close with one thread before load.
Load test WebSocket APIs with JMeter plugins: install options, open/message/close flows, auth tickets, CLI runs, and injector sizing for long-lived sockets.
Apache JMeter’s core distribution focuses on protocols such as HTTP, JDBC, JMS, LDAP, and FTP (see the component reference sampler list). WebSocket is not a built-in core sampler in the same way HTTP Request is. Production WebSocket load tests with JMeter almost always depend on the plugin ecosystem (JMeter Plugins / Plugins Manager and community WebSocket plugins). This guide explains a grounded, plugin-aware workflow: install plugins, design sessions, correlate, size threads, and operate CLI load without overstating what core JMeter alone can do.
A WebSocket client:
Load dimensions differ from REST:
| Dimension | REST-style HTTP | WebSocket |
|---|---|---|
| Connection | Often short (keep-alive pool) | Long-lived per VU |
| Metric focus | Request latency, RPS | Connect time, message latency, msg/s, errors, connection drops |
| Thread usage | Sample ≈ request | Thread may block on read/write for the session lifetime |
| Memory | Per-sample buffers | Per-open connection state |
JMeter’s thread model (best practices on sizing threads) still applies: each concurrent session typically needs a thread (or plugin-specific async mode if offered). Undersizing threads relative to message rates invites coordinated omission style bias.
Core JMeter does not install third-party plugins by itself. Community practice:
jmeter -n.Distributed testing requires identical plugins on every worker. Missing plugin JARs cause serialization or class-not-found failures remotely.
Test Plan├── HTTP Request Defaults / Header Manager (auth bootstrap)├── CSV Data Set (users)└── Thread Group ├── HTTP Login (core) + extract token ├── WebSocket Open (plugin) // pass token via query/header if supported ├── Loop Controller │ ├── WebSocket Write/Ping (plugin) │ ├── WebSocket Read (plugin) + assertions/extractors if available │ └── Timer (pace messages) └── WebSocket Close (plugin)Exact sampler names depend on the plugin (Open, Single Read, Single Write, request-response, ping/pong, etc.).
| Pattern | Approach |
|---|---|
| Ticket in query string | Extract from HTTP, use \${ticket} in open URL |
| Bearer on upgrade | Plugin header fields if supported; else query ticket |
| Cookie session | Cookie Manager + open to same host |
| Subprotocol | Plugin field for Sec-WebSocket-Protocol when required |
Use JWT/OAuth guidance for the HTTP side. Never hard-code long-lived tokens in the plan.
Payloads: prefer variables and CSV over huge embedded binaries. Functions such as \${__UUID} and \${__time} help unique message ids (functions).
If the server pushes an id you must echo:
\${msgId}.\${msgId}.If the plugin does not expose body to standard post-processors, check plugin-specific “read to variable” options in its documentation.
Same lean rules as HTTP (best practices):
jmeter -n -t websocket-plan.jmx -l results.jtl -e -o report/ \ -Jthreads=200 -Jrampup=120 -Jhost=ws.example.comFrom JMeter results (labels you control) plus optional Backend Listener:
HTML dashboard still works on the JTL if samples are recorded as standard SampleResults.
wss://) needs correct JVM trust stores, same as HTTPS.| Symptom | Checks |
|---|---|
| Sampler missing in GUI | Plugin not installed / wrong JMeter version |
| Works in GUI, fails in CI | Plugin absent in CI image |
| 401 on open | Token query/header not correlated |
| Handshake fail | Proxy, TLS, wrong scheme ws vs wss |
| Threads stuck | Blocking read without timeout; plugin timeout settings |
| OOM | Too many open sessions per JVM; raise heap or split engines |
WebSocket support is provided through the plugin ecosystem, not as a primary core sampler like HTTP Request. Install a maintained WebSocket plugin via Plugins Manager or manual JARs.
The recorder is built for HTTP(S) request/response capture. Do not expect full WebSocket frame recording the way you record REST calls. Build socket steps with the plugin after HTTP login.
Often one thread per concurrent connection for classic Thread Groups. Size from concurrent sessions and message pacing, then validate injector CPU, RAM, and file descriptors.
Yes. Workers must match the controller’s JMeter version and plugin set, same as other third-party engines in remote testing.
Yes. If the plugin writes standard sample results, -e -o report/ works. Label connect/write/read/close clearly for readable statistics.
On this page