It’s apparent that the usage of Websocket has expanded greatly in recent years, and its reliability is expected to be high since it mostly carries crucial information to clients. Hence, testing their durability and reliability has become more important.
Let’s take a look at the plugin first.
You can download the plugin here.
Once you install the plugin, you will get 7 new Sampler elements:
Websocket Close: Closes the current Websocket connection
Websocket Open Connection: Initiates a new connection with given parameters, with options for connection&read timeouts
Websocket Ping/Pong: Performs a ping or ping/pong service for the current connection
Websocket Sampler: A single sampler that performs one-time request.
Websocket Single Read Sampler: Reads response without sending a request.
Websocket Single Write Sampler: Sends a request without reading the response
Websocket request-response Sampler: Does both sending a request and reading response
Websockets’ behavior may reveal differences between each other, but the structure of a script for Websocket is usually similar to the following format:
Initiating a connection with Websocket
Sending the first request
Receiving the first request
Using a looper (Runtime controller or Loop Controller etc.) to continue the data transmission between the client and the server by sending a message and receiving it.
-First, we need to start a connection with the Websocket. It can be done either using “Websocket Open Connection”, or “Websocket Request” with the “setup new connection” option.
-The information about the sockets needs to be given. For example, you can find the socket’s information from Google Chrome’s Inspect mode>Network>WS
-There is one another situation that requires a token that is received by another request for a Websocket to initiate a connection.
-When the connection has started, there will be a series of messages that will be transferred from both the client and the server-side. Some of the requests going from the client might be unique, but at some point, repetitive pattern requests can be seen and it will be imitated with a loop logic. Additionally, this repetitive pattern usually has a constant interval between requests, which might need to be taken into account.
That's it, happy testing!
If you don't see the answer to your question here, please reach out to us to let us know! We're always improving our documentation.