JMeter pressure test based on WebSocket protocol

Source: Internet
Author: User
Tags format message

WebSocket protocol is a new protocol for HTML5. It implements browser-to-server full-duplex communication (Full-duplex). Browsers and servers only need to do a handshake, and then a fast channel is formed between the browser and the server. The data can be transmitted to each other directly between the two. In this WebSocket agreement, there are two major benefits to our Instant service: 1. Headers that communicate with each other are very small-about 2 Bytes2. Server Push Browser Request
Get/websocket/livevideo http/1.1upgrade:websocketconnection:upgradehost:localhost:8080             (client request host) Origin:http ://127.0.0.1         (Source page address) sec-websocket-key1:23 asdfjkj,asdjksec_websocket-key2:wewerw234 jij9980x13x10 + 8 bytes sec_ Websocket-key3 value, no key name (note, here the 0x13x10 of the extra, also say there are two consecutive 0x13x10)

Server response

http/1.1 101 Web Socket Protocol handshakeupgrade:websocketconnection:upgradesec-websocket-origin:http://127.0.0.1< c1/> (source page address) Sec-websocket-location:ws://localhost:8080/websocket/livevideo

JMeter Test Webocket Protocol

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

After the download is complete, drop it directly into the JMeter \lib\ext\ directory. This plugin is available for restart JMeter.

Start JMeter, right-click Test Plan, add->threads (users), thread group->sampler->websocket Sampler

WebSocket Sampler Page

Main Options Description:

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.

To test

Test Address: http://www.websocket.org/echo.html

After adding WebSocket sampler, add a View results tree and run to see the results.

JMeter pressure test based on WebSocket 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.