Apache JMeter has no WebSocket sampler out of the box: to test WebSockets in JMeter, install the WebSocket Samplers by Peter Doornbosch plugin through the Plugins Manager (an older alternative is the WebSocket Sampler by Maciej Zaleski). The plugin adds six samplers: WebSocket Open Connection, WebSocket request-response Sampler, WebSocket Single Write Sampler, WebSocket Single Read Sampler, WebSocket Ping/Pong and WebSocket Close. With them a thread group opens a WebSocket connection, sends and reads frames over the existing connection and closes it, so one JMeter thread plays one client of a chat, a trading screen or another real time application. That matters because a WebSocket server is loaded by connections that stay open, not only by requests: open connections hold memory and sockets on the server even when they are quiet, so a load test has to keep them open the way real clients do. This guide is for performance engineers and QA teams who need WebSocket load testing with JMeter. It shows how to install the plugin, what each sampler does, a test plan you can copy and the limits you should know before you trust the numbers. Then it shows how to run the same JMX file on PFLB Platform load generators, strictly as the PFLB documentation describes it. We checked the facts on 16 November 2026 against the plugin source and README, the JMeter Plugins catalogue, the Apache JMeter manual and the PFLB documentation.
Can You Test WebSockets in Apache JMeter Without a Plugin?
Not in the core. The JMeter component reference lists samplers for HTTP, FTP, JDBC, LDAP, TCP, SMTP and other protocols, and none of them speaks the WebSocket protocol (Apache JMeter, Component Reference). WebSockets are a persistent, two-way connection: the browser or app opens it once and then client and server send messages in both directions whenever they need to. To test WebSockets you need samplers that hold that connection across several steps of a test plan, and in JMeter those come from a plugin.
Two plugins are listed in the JMeter Plugins catalogue (jmeter-plugins.org repository):
| Plugin | Catalogue ID | Samplers | Latest version we found |
|---|---|---|---|
| WebSocket Samplers by Peter Doornbosch | websocket-samplers | Six samplers, three frame filters and a binary response assertion | 1.3.2, published to Maven Central in January 2026 |
| WebSocket Sampler by Maciej Zaleski | websocket-sampler | One WebSocket Sampler | The catalogue lists 1.0.2-SNAPSHOT; the last release on GitHub, 1.0.3, is from August 2021 |
For a new test plan, use the Peter Doornbosch plugin: it is maintained, the catalogue entry calls it a plugin for "load testing WebSocket applications", and the rest of this guide uses it. If you inherited a script built on Maciej Zaleski's sampler, keep that plugin installed next to it; PFLB Platform supports both, as the section below shows.
Install the Peter Doornbosch WebSocket Plugin with the Plugins Manager
- If your JMeter has no Plugins Manager in the Options menu, download the Plugins Manager JAR and put it into JMeter's
lib/extdirectory, then start JMeter (JMeter Plugins, Plugins Manager). - Open Options, Plugins Manager, go to the Available Plugins tab and tick WebSocket Samplers by Peter Doornbosch.
- Click Apply Changes and Restart JMeter. After the restart the samplers appear under Add, Sampler in any thread group.
You can also download the jar and copy it to <jmeter-home>/lib/ext by hand, or get it from Maven Central if JMeter runs in a build pipeline (plugin README). On a build agent or a load generator without a GUI, the Plugins Manager has a command line tool (JMeter Plugins, automated install):
PluginsManagerCMD install websocket-samplers
PluginsManagerCMD install-for-jmx /path/to/websocket-test.jmx
The second command reads a test plan and installs every plugin it needs, which is handy when the same JMX file runs on several machines. The README asks for Java 8 or later (with Java 7 the plugin fails to load without an error) and, from plugin version 1.0, JMeter 3.1 or later.
JMeter WebSocket Samplers: Open Connection, Request-Response, Single Read, Single Write, Ping/Pong and Close
Every sampler that opens or uses a connection has the same connection block in its GUI. Under Server URL you choose ws or wss, then enter the WS server name or IP, the port and the path. Under Connection you choose "setup new connection" or "use existing connection" and set the connection timeout (ms) and the response (read) timeout (ms). These timeout values decide how long a sampler waits before it fails, so set them from your requirements rather than leaving defaults you never checked. Like any other JMeter sampler, each WebSocket sampler records its response time and result, so throughput and errors per step show up in the usual listeners and reports.
| Sampler | What it does | Settings to know |
|---|---|---|
| WebSocket Open Connection | Sends the upgrade request and opens the WebSocket connection without sending data. Use the WebSocket Open Connection sampler as the first request of a session | Server URL, connection timeout, read timeout for the upgrade response |
| WebSocket request-response Sampler | Sends one text or binary frame and reads one frame back, much like an HTTP request and response. The README calls it the most commonly used sampler | Request data, text or binary, new or existing connection |
| WebSocket Single Write Sampler | Sends one text or binary frame and does not wait for an answer | Request data, optionally loaded from a file; text or binary |
| WebSocket Single Read Sampler | Waits for one text or binary frame, for example a message the server pushes | Response (read) timeout; text or binary; an optional read, where a timeout is not an error |
| WebSocket Ping/Pong | Sends a ping frame and waits for the pong frame that answers it (the option is labelled "send ping, expect pong"), or just sends an unsolicited pong message | Pong (read) timeout |
| WebSocket Close | Sends a close frame with a close status and waits for the server's close response, so the WebSocket close is clean | Close status, read timeout |
The sampler names above are the names the plugin shows in JMeter (taken from its source code). The PFLB documentation lists the last one as WebSocket Close Connection.
Binary Frames, the WebSocket Binary Frame Filter and Other Config Elements
Many real time applications send binary data, not only text. The request-response, single read and single write samplers support binary frames: to send binary data, enter the payload in hexadecimal, for example 0xca 0xfe, and JMeter variables can be used if they resolve to hex at runtime. If the request data is loaded from a file, it is sent as is, so keep binary content in binary files (plugin README). The plugin also adds a binary view to the View Results Tree listener (choose Binary in the type list if the response tab stays empty) and a Binary Response Assertion.
Servers often push frames the test did not ask for: pings, heartbeats, presence updates in chat applications. The plugin adds three config elements under Add, Config Element that discard such frames before a sampler sees them:
- Ping/Pong frame filter: drops ping and pong frames and can answer pings automatically.
- WebSocket binary frame filter: drops binary frames, or only those that match a byte sequence.
- Text frame filter: drops text frames that contain or match a string or regular expression.
Filters work in the scope where you put them, like other config elements. Filtered frames still appear as subresults in the tree listener, but by default they are not counted in received bytes; set the property websocket.result.size_includes_filtered_frames=true if throughput must reflect everything on the wire.
Example: A WebSocket Load Testing Test Plan in JMeter
The plan below models one client of a chat or quote stream: it connects, subscribes, reads what the server pushes, checks the connection with a ping and closes. A WebSocket connection is stateful and belongs to one virtual user: one thread is one client, so the thread count is the number of concurrent WebSocket connections.
Test Plan
└── Thread Group (users = concurrent connections)
├── HTTP Header Manager (headers for the upgrade request, e.g. Authorization)
├── HTTP Cookie Manager (session cookies sent with the upgrade)
├── Ping/Pong Frame Filter (drop pings, answer them automatically)
├── WebSocket Open Connection (wss, server, port 443, path /ws)
├── WebSocket request-response Sampler (use existing connection, {"action":"subscribe"})
├── Loop Controller (N reads)
│ └── WebSocket Single Read Sampler (use existing connection, response timeout)
├── WebSocket Single Write Sampler (use existing connection, {"action":"ping-app"})
├── WebSocket Ping/Pong (use existing connection)
└── WebSocket Close (close status 1000)
A few details make this plan behave:
- Headers and cookies. The plugin takes headers from the HTTP Header Manager and cookies from the Cookie Manager and sends them with the upgrade request, so a token or session cookie from an earlier HTTP Request sampler that logs in reaches the WebSocket server (plugin README).
- wss and the port. For wss, also change the port, usually to 443, or the TLS handshake will go to an HTTP port and fail in confusing ways.
- Existing connection. Every sampler after Open Connection uses "use existing connection". If a sampler is set to set up a new connection, the old one is closed at TCP level without a close frame.
- Clean shutdown. If a thread ends without the WebSocket Close sampler, the connection stays open until JMeter cleans up. Set the property
websocket.thread.stop.policy=wsCloseto send a close frame when each thread stops.
Debug the plan with a few threads in the GUI and the View Results Tree listener, then run the load in non-GUI mode (Apache JMeter, Getting Started):
jmeter -n -t websocket-test.jmx -l results.jtl -Jwebsocket.thread.stop.policy=wsClose
Honest Limits of WebSocket Performance Testing in JMeter
The plugin works the way JMeter works, and some of that matters for WebSocket performance testing:
- One active connection per thread. The README says each thread can have at most one active WebSocket connection. To hold 5,000 open connections you need 5,000 threads, and a thread that waits on a read cannot do anything else.
- Frames, not messages. The plugin reads frames. If the server splits a message into fragments, you add a read per continuation frame or a loop on the
websocket.last_frame_finalvariable. - Read timeouts with filters. When filters drop frames, the time spent filtering is subtracted from the read timeout, so treat the timeout as the maximum time to wait for a message.
- Message formats are yours. The samplers send and read raw text or binary frames. Any message format your application builds on top of WebSocket you script yourself in the request data and check with assertions.
- TLS certificates are not verified. As in standard JMeter, server certificates are accepted without verification. Client certificates are supported through JMeter's SSL settings.
- One machine has limits. Long-lived connections use memory and sockets on the load generator. For a large number of connections you spread the test over several machines and collect the results yourself.
Run the Same WebSocket JMX on PFLB Load Generators
If you would rather not set up and watch those machines yourself, you can import the same JMX file into PFLB Platform. According to the release notes for version 1.11, "the PFLB Platform now supports testing of the WebSocket protocol", and WebSocket samplers are shown in the thread groups of JMX tests (PFLB docs, release 1.11). The list of supported plugins includes both WebSocket Samplers by Peter Doornbosch and WebSocket Samplers by Maciej Zaleski (PFLB docs, supported plugins and elements).
What the documentation describes:
- Import. Click + New Test, then Import from JMeter, and upload the JMX file (up to 100 MB) and the files it uses, such as CSV data. The platform creates a container for the script (PFLB docs, import from JMX). If a script contains an unsupported plugin, it is not imported, so check the list first.
- The WEBSOCKET label. For JMX scripts that use the WebSocket protocol, the thread group view shows a WEBSOCKET label and the samplers it uses: OPEN CONNECTION, PING PONG, SINGLE READ, SINGLE WRITE, REQUEST RESPONSE and CLOSE CONNECTION for the Peter Doornbosch plugin, and MESSAGES for the Maciej Zaleski WebSocket Sampler.
- Supported, not edited in the platform. The WebSocket samplers are in the list of samplers that are supported but that you can't change in the platform GUI. To change a WebSocket step, edit the script in JMeter and use Re-upload in the container.
- Load profile. The documentation recommends jp@gc - Ultimate Thread Group for imported JMX scripts; for it, the platform shows the load profile and lets you change it. Other thread group types are supported but not changed in the GUI.
- Monitoring and webhooks. Link a settings set to add system metrics of the tested servers and webhooks that fire when the test status changes. For JMX tests, the documentation says that only the monitoring and webhook settings of a settings set apply.
- Results. After the import, listeners in the script are disabled (PFLB docs, supported plugins and elements). The results of the run are shown in the platform's Grafana dashboards, including one for comparing two test runs and one for system metrics (PFLB docs, visualizing tests in Grafana), and you can build a report from a run in the report editor or with AI (PFLB docs, reports).
The same import page describes copying the container with the script to add load and choosing a region for each container. How that works for JMeter scripts in general is covered on our distributed JMeter testing page.
The documentation does not describe editing WebSocket samplers in the platform's test editor, recording WebSocket traffic in the platform or protocol-specific handling of message formats on top of WebSocket. The platform runs the WebSocket steps that are in your JMX file, so the script stays the place where you build and change them.
Which Route Fits
| JMeter on your own machines | The same JMX on PFLB Platform | |
|---|---|---|
| Where you build the WebSocket steps | JMeter with the plugin | JMeter with the plugin; the platform does not edit them |
| Load generators | Machines you install, size and connect | Platform load generators |
| Load profile | In the thread group | In the platform for Ultimate Thread Group, in the script for other types |
| Server monitoring | A separate setup | A settings set with monitoring, linked to the test |
| Results | Your listeners and files | Grafana dashboards, run comparison and reports in the platform |
| A good fit | A small test, or a team that already runs its own load infrastructure | A team that wants to run a WebSocket JMX at scale without managing generators |
Both routes start from the same test plan. Build and debug it locally with a handful of threads, then decide where the full run should happen.
If you want help with the load model behind a WebSocket test, such as how many connections, which messages and what pass criteria, PFLB's performance engineers design the scenarios, write the scripts and run the tests with you.