A high-performance Server-Sent Events (SSE) sampler plugin for Apache JMeter. Enables load testing of real-time streaming HTTP endpoints with full support for custom authentication headers, configurable listen duration, and accurate JMeter metrics reporting.
- ✅ Native SSE protocol support (
text/event-stream) - ✅ Custom request headers (e.g.
Authorization: Bearer <token>) - ✅ Configurable listen duration (seconds)
- ✅ Accurate JMeter metrics: Load Time, Connect Time, Latency, Bytes, Throughput
- ✅ HTTP error detection: 401, 403, 500 responses reported as failures
- ✅ Thread-safe shared
OkHttpClientconnection pool (no resource leaks) - ✅ JMeter variable interpolation:
${myVar},${__P(prop)} - ✅ Graceful shutdown — no socket leaks on test stop
- Install JMeter Plugins Manager
- Open JMeter → Options → Plugins Manager
- Search for "SSE Sampler"
- Click Apply Changes and Restart JMeter
Download the latest jmeter-sse-sampler-*.jar from the Releases page and copy it to your JMeter lib/ext/ directory:
cp jmeter-sse-sampler-1.0.0.jar $JMETER_HOME/lib/ext/Restart JMeter.
- Add a Thread Group to your test plan
- Right-click Thread Group → Add → Sampler → SSE Sampler
- Configure the sampler:
| Field | Description | Example |
|---|---|---|
| SSE Endpoint URL | Full URL of the SSE endpoint | https://api.example.com/events |
| Listen Duration (seconds) | How long each thread listens for events | 30 |
| Custom Request Headers | One Name: Value pair per line |
Authorization: Bearer ${token} |
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
X-Tenant-Id: acme-corp
X-Request-Id: ${__UUID()}
After each sample, the following metrics are reported to JMeter:
| Metric | Description |
|---|---|
| Load Time | Total duration the sampler listened for events |
| Connect Time | Time until the first HTTP response headers were received |
| Response Code | HTTP status code (200, 401, 500, etc.) |
| Response Message | OK — 42 events received or error description |
| Response Body | All received SSE events in `ID |
| Bytes | Total bytes of received event data |
- Java 11+
- Maven 3.6+
git clone https://github.com/YOUR_USERNAME/jmeter-sse-sampler.git
cd jmeter-sse-sampler
mvn clean packageThe shaded (fat) JAR will be created at:
target/jmeter-sse-sampler-1.0.0.jar
This JAR bundles all required dependencies (OkHttp, Kotlin stdlib) and can be dropped directly into JMeter's lib/ext/.
| Dependency | Version | Scope |
|---|---|---|
com.squareup.okhttp3:okhttp |
5.3.2 | bundled |
com.squareup.okhttp3:okhttp-sse |
5.3.2 | bundled |
org.apache.jmeter:ApacheJMeter_core |
5.6.3 | provided |
The OkHttpClient is shared across all JMeter threads via a static final field. This means all virtual users share a single connection pool, which is the correct OkHttp usage pattern for high concurrency.
When the listen duration expires, the plugin:
- Sets an
intentionalCancelflag - Calls
eventSource.cancel()to close the socket - OkHttp's resulting
onFailurecallback is suppressed via the flag - All JMeter result fields are written on the JMeter thread (no race conditions)
log.debug— per-event logging (disabled by default in JMeter)log.info— per-sample summary (connection open/close, event count)log.error— actual failures only
To enable debug logging, add to $JMETER_HOME/bin/log4j2.xml:
<Logger name="io.github.cuneytcakir.jmeter.sse" level="debug"/>Pull requests are welcome! Please open an issue first to discuss what you would like to change.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is licensed under the Apache License 2.0.
- Built with OkHttp by Square
- Inspired by the JMeter Plugins ecosystem