JMeter - I need to open and keep multiple websocket connections at the same time to be able to use them in parallel in JMeter - websocket

I am using JMeter to test our websockets server API and now I have the following issue. I need to open and keep multiple WS at the same time to be able to use them in parallel.

JMeter WebSocket Samplers plugin provides possibility:
To open a WebSocket connection via WebSocket Open Connection sampler
And then you can re-use the connection in the following Samplers which will be doing the real work: read, write
When you don't need the connection anymore you can use WebSocket Close sampler
The connections are established "per thread" (virtual user) so provide necessary amount of concurrent threads in the Thread Group and make sure to specify enough loops or the desired duration of the test
More information: JMeter WebSocket Samplers - A Practical Guide

Related

Multiple Parallel Websocket connections to SignalR hub in JMeter

We are trying to load test our login workflow, by simulating 50+ users logging into our front-end, via the API calls. As part of the login process, we make a websocket connection to a SignalR hub(Connect). We then send a call over the websocket connection to a custom endpoint in SignalR(Login), used to add some data to the Redis cache, then do some stuff which isn't important, then send a call to a different custom endpoint over the websocket connection(Logoff) and then Disconnect the websocket connection.
So my question is multi-part:
How do we create a websocket connection from within JMeter?
How do we make a call to a custom endpoint over the websocket connection in JMeter
How do we do this for multi users simulated to be running in parallel, so we can test the load? In other words, we need multiple websocket connections open / alive from JMeter so we can test the load.
Note: Please be aware, I'm asking this on behalf of the load tester/JMeter developer, but because they are new to Stack Overflow, and I understand the SignalR side, I've been asked to log it. I know zip about JMeter, so please handle me like a noob trying to help someone solve a frustrating but important problem.
JMeter per se doesn't support WebSockets, you will need a special plugin if you want to enable this functionality.
The most advanced, comprehensive and supported as of now is JMeter WebSocket Samplers by Peter Doornbosch, it can be installed using JMeter Plugins Manager
Once you install the plugin and restart JMeter you will see several new samplers which will allow to open connection, send request, read response, and close connection.
Unfortunately I cannot guide you further because I don't know the specifics of your application, just look into your browser developer tools or other sniffer tool and configure JMeter to send the same requests as your browser (or other application) does.
More information:
Test SignalR Performance with JMeter
JMeter WebSocket Samplers - A Practical Guide
samples directory contains several example test plans covering different scenarios

How to use existing websocket connection to another websocket request in jmeter?

How to use existing websocket connection to another websocket request in jmeter?
When I tried to use existing connect then as result it show me an error "Sampler configured for using existing connection, but there is no connection" . Please refer attached screenshot.
enter image description here
enter image description here
It looks like you're using 2 different WebSocket Samplers implementations:
JMeter-WebSocketSampler
and JMeter WebSocket Samplers
Your WebSocket Single Write Sampler:
Doesn't know anything about the connection established by the WebSocket Sampler
The WebSocket Sampler closes the connection after receiving the response
So if you want to continue with the WebSocket Single Write Sampler you need to:
Use WebSocket Open Connection sampler to establish the connection:
In the WebSocket Single Write Sampler tick use existing connection box
More information: JMeter WebSocket Samplers - A Practical Guide
If you want to continue with the WebSocket Sampler - tick Streaming connection box:
and remove the WebSocket Single Write Sampler and friends from the Test Plan

In jmeter, how can I keep a websocket connection for later use

I just have a load test in JMeter, in the test, the client will send several requests in few seconds. But I find a problem when the client makes a new request, the JMeter will close the former connection and create a new connection, I just want to reuse the former connection to send a request to the WebSocket server.enter image description here
Just tick use existing connection box in your WebSocket Samplers and the connection established by the WebSocket Open Connection sampler will be re-used
I believe the connection doesn't survive Thread Group iterations (it's basically re-established when Open Connection sampler is executed 2nd time, if you need to repeat the request more than once - either go for Loop Controller or put the Open Connection sampler under the Once Only Controller
More information: JMeter WebSocket Samplers - A Practical Guide

JMeter - Opening multiple websocket connections in parallel

The application that I am testing has multiple WebSocket sub-protocols. So, is there a way to open multiple websocket connections in parallel using JMeter?
My current test plan looks like this:
Thread Group
\_ Websocket Open connection 1 (with subprotocol 1)
\_ Websocket request-response samplers
\_ Websocket Open connection 2 (with subprotocol 2)
\_ Websocket request-response samplers
But when I open connection 2, connection 1 is automatically closed. I am looking for some way to hold both open simultaneously. Any help is appreciated!
Please note that I am using Peter Doornbosch's JMeter WebSocket Samplers (from https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/master/).
Thanks in Advance.
When WebSocket Open Connection sampler is invoked it instantiates WebSocketClient establishing the connection with the backend and puts the instance into Thread-Local storage
If there is an active connection at this phase - it will be closed.
So you cannot have > 1 websocket connection for 1 JMeter Thread (virtual user)
The options are in:
Just remove Websocket Open connection 2 (with subprotocol 2) along with its Websocket request-response samplers and parameterize subprotocol using i.e. CSV Data Set Config so 1st virtual user will establish connection with subprotocol 1 and 2nd virtual user will go for subprotocol 2
Put your construction under the Parallel Controller
Not knowing the full context it's hard to recommend something, personally I would go for option 1
You could try the (experimental) multi-connection support that is available on a separate branch, see https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/multiple-connections/. The readme explains how to use it. You'll have to build the plugin yourself, but that's fairly easy and also documented in the readme.

JMeter recording use non http/https protocol

I am recording our game app using JMeter
And it has an API server, which using the WebSocket's protocol
While meeting that request sent to API server, I always get this message, and can't go further
Is that means I need to modify the original JMeter's source code to walk around this problem? Or any way out? If so, that'd be appreciated.
I don't think you will be able to record and replay WebSocket transport using JMeter's HTTP(S) Test Script Recorder as WebSocket is a different beast, given you have a game application my expectation is that it might be the case application opens a WebSocket connection and re-uses it until the end of session and so you won't be able to mimic this behavior using "normal" HTTP Request samplers as WebSocket assumes either ws or wss protocol.
I would suggest considering one of the following JMeter Plugins:
WebSocket Sampler by Maciej Zaleski
WebSocket Samplers by Peter Doornbosch
Both plugins can be installed using JMeter Plugins Manager:

Resources