WebSocket is a TCP-based protocol that HTML5 applications use to establish an interactive two-way connection between a web client and a web server. The protocol includes a handshake and a data transfer.
Supported WebSocket Versions
LoadComplete supports the following WebSocket versions:
What Does WebSocket Support Mean
LoadComplete can detect socket connections established during the scenario recording and record messages the client and server send through the connection.
You can examine the WebSocket opening and closing handshakes and recorded messages in the Scenario editor:
The client and server send messages asynchronously and independently of each other. LoadComplete records the messages the client sends and the messages the server sends separately (unlike the regular HTTP traffic, for which LoadComplete records client requests with appropriate server responses).
LoadComplete decodes the data the messages contain. You can view the data on the WebSocket page of the Scenario editor. You can parameterize client messages with data LoadComplete gets from external files or from preceding web server’s responses. You can also set validation rules for server messages to make sure that your tested web server sends correct data.
You can simulate the recorded WebSocket traffic with the needed number of virtual users to see how your web server works under the load.
During the test run, LoadComplete will simulate the recorded opening handshake, client messages and the closing handshake (if any). It will post information on simulated client messages and the messages the server will send to the client during the test run to the test log.
By default, the recorded server messages are disabled. LoadComplete will not simulate them. However, LoadComplete still will simulate the think time recorded for server messages.
To view and edit the think time, select the needed WebSocket message. The Think Time edit box of the Operation Editor panel shows the recorded think time. If needed, modify the think time.
|Edit the recorded think time cautiously. If you set a zero think time for all messages, there can be a situation when your tested web server is still processing last client requests while your load tests is already waiting for the close connection message. In this case, your load test may report errors.|
Asynchronous and Synchronous WebSocket Server Messages
By default, data transfer in the WebSocket protocol is asynchronous. The client and server send messages independently of each other.
Why LoadComplete Disables Asynchronous WebSocket Server Messages
During asynchronous data transfer, the number of server messages, their order, and their content might be arbitrary. LoadComplete disables server response messages in recorded WebSocket scenarios and does not wait for them during the test run. It gets actual messages the server sends to the client, but does not match them with the recorded server messages.
Enabling Synchronous WebSocket Server Messages
If your client and web server send messages through a socket connection synchronously, the order of server messages depends on the client messages. Therefore, you may want to verify your server messages during the test runs.
You can configure the recorded scenario to wait for appropriate server messages during the test run. To do this, enable the needed server messages in the scenario:
Open the scenario in the Scenario editor.
In the Scenario Explorer, select the server message you want to enable. Use CTRL+click and SHIFT+click for multi-selection.
Right-click the response message and select the Enable check box in the context menu.
During the test run, LoadComplete will match the recorded and actual messages and post information on them to the test log. You may need to enable the View Recorded Body option on the test log toolbar to view server message contents.
|To match server messages, LoadComplete compares their Opcode field values. It checks neither their contents, nor size.
If the Opcode values of the actual and the recorded server messages are different, an error will occur.
How You Parameterize WebSocket Messages
You can parameterize the messages your web client sends to your tested web server over the established socket connection, that is, you can replace the recorded data in client messages with variables containing various data. For example, the variables can contain data LoadComplete gets from external files or from server responses.
Open your scenario for editing.
To parameterize an individual client message, open its Data Replacers tab. To parameterize multiple client messages, open the Data Replacers tab of the Scenario operation (the scenario top-level node). You can parameterize only the messages that send text data.
Create a rule (or several rules) that will replace the recorded data in the message (or messages) with the variable.
For detailed information on parameterizing requests, see Parameterizing Requests.
Specifics of WebSocket Support
Important: LoadComplete cannot detect and record WebSocket messages if the connection, through which these messages are sent, was established before you started the recording.
Always start the recording of WebSocket traffic with performing user actions that will open the needed WebSocket connection in your web browser. For example, depending on your web application, you may need to refresh the web page, or click some "connect" button, or log in anew to your web application, and so on. Otherwise, LoadComplete will not record WebSocket messages.
If you record several scenarios in a row, start the recording of each scenario with performing the needed user actions that will open the WebSocket connection (you can later delete or disable redundant requests in recorded scenarios).