JMeter Test Webocket Protocol

Source: Internet
Author: User
Tags format message

The jmeter itself does not support the WebSocket protocol, so you need to install a third-party plugin with 6 dependent packages.

First, we need to prepare the support plugin for the JMeter websocket protocol:

Jmeterwebsocketsampler-1.0.2-snapshot.jar This plugin relies on several jar packages 1, JETTY-HTTP-9.1.2.V20140210.JAR2, Jetty-io-9.1.2.v20140210.jar3, JETTY-UTIL-9.1.2.V20140210.JAR4, WEBSOCKET-API-9.1.1.V20140108.JAR5, WEBSOCKET-CLIENT-9.1.1.V20140108.JAR6, Websocket-common-9.1.1.v20140108.jar

After we've prepared these jar packages, we'll copy them to the \lib\ext\ directory of the JMeter directory, restart JMeter, and we'll see WebSocket Sampler (if not, it could be that the JDK version is too low, I'm using 1.8)

Here are the steps:

Right-click Test Plan, add->threads (users), thread groups, such as

Again, select the right mouse button to select the thread group that you added, add->sampler->websocket Sampler, as

Next, take a look at WebSocket's page

Explain the meaning of the items

1, WebServer
(1) address or name of the destination server sent by server name or Ip:websocket
(2) port number the Port Number:websocker server listens on. (typically an HTTP 80 port, which can be obtained via Wireshark packets)


2. Timeout:
(1) connection– The maximum time, in milliseconds, that JMeter waits for a connection to complete after sending a connection request.
(2) Response-The maximum wait time for the response message.


3. WebSocket Request
(1) implementation– only supports RFC6455 (V13), the latest version of the WebSocket protocol standard.
(2) protocol– has WS and WSS, the WS prefix is the distinguished identity of the WebSocket connection, and the WSS prefix is the distinguished identity of the WebSocket secure connection. Fill in according to your actual situation
(3) Streaming connection– Select this TCP session to maintain, if the hook on the identity of the connection will always exist, if not checked, then the first response after the link will be closed.
(4) Request data: Fill in the requests to be sent, to communicate with the development of good, this is what format message.


4.WebSocket Response
(1) Response pattern– Sampler will wait for the message containing the identity and continue to communicate (or until timeout, the connection is closed)
(2) Close Connection pattern– If the message returned by the server contains such a character, it ends the session.
(3) Message backlog– defines the maximum length that the server returns message retention.

JMeter Test Combat

Grab the WebSocket package using Google Chrome (press F12, select Network, filter ws)

Test Plan tree as

A parameterized file was added (JMeter has several parameterization methods, here are examples of CSV)

In Configure the CSV Data source group: 1, Filename: The full path of the. bat file that was requested in the previous step, 2, File encoding: The encoding format of the document, according to the actual situation; 3, Variable Names (comma-delimited): field name, multiple comma-separated 4, Delimiter (use ' \ t ' for tab): Define delimiters, such as commas, directly fill in the comma symbol 5, allow quoted data? : The option to "true" when the processing of full-width characters is garbled 6, Recycle on EOF: Whether to iterate, CSV Data Set config read one line at a time, split into a number of variables to a thread, if the number of threads more than the number of record lines of text, Then you can choose to read the 7 again from the beginning, Stop thread on EOF? : When recycle on EOF is false, when the file is read to the end, the process is stopped, and when recycle on EOF is true, the item is not meant to be set according to the actual situation. After all the settings are complete, save. It is important to note that if the configuration is not correct, you can postpone parameterization, directly in the WebSocket page fill in Request data, run, view the results, if successful return, at the beginning of the parameterization. Execute the JMeter test plan to see the results of the send and server returns in the results tree, such as:

JMeter Test Webocket Protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.