Friday, July 10, 2015

JMETER - Web Socket Testing

How test the Web Socket through Web Socket plugin for Jmeter?

 1. How to add the PLUGIN?


1.Download the Jmeter from the following Link. Download Binaries(.zip)

2.Download the following Web Socket Project 

3.Unzip and import the Project as Maven project to your work space in Eclipse. Run the Maven command to package and install.

4.New jar will be created in the Project. Copy the JMeterWebSocketSampler-1.0.2-SNAPSHOT.Jar and paste it in apache-jmeter/bin/ext folder. Restart the Jmeter. After restarting the Jmeter you can notice websocket sampler as shown in below snapshot.



5. This Jmeter Plug-in supports RFC6455 version of Web Socket protocol. 

Features:
a) Supports HTTS/HTTPS (ws/wss) version of the WebSocket protocol.
b) Option to ignore SSL certificate errors.
c) Streaming allows for a single connection to remain open for the duration of the test.
d) Response has to match predefined regular expression 
e) Response timeout.
f) Response message backlog (build the Sampler response from multiple server messages).
g) Connection could be closed if server sends a message matching predefined regular expression.

6. Open the Application in Chrome Browser for which you need to test web socket. Presss F12 and go Web Console. Click on Network, and again click on WebSockets. Refresh the Page. You will be able to see Web Socket in left panel and under Frames; you will be able to see the Request and Response
(example: Request as 2probe and Response as 3 probe).

7. You may have to replicate these requests in Jmeter to establish the web socket connection.

8. Let see how to send request and Response in Jmeter using Web Socket Plugin.

9. In our Application Web Socket has not been implemented directly, Socket.IO Libraries in turn create the Web Sockets. Also, Application maintains a session. So I will be using an HTTP Request initially and extracting the Socket ID.

10. Fill the Header referring the Browser Web Console.

11. Add the Web Socket Sampler.

Parameters:

a. Connection ID: Pass the Session ID as parameter, which was extracted in previous request.
b. Time Outs : You check the Application Timeout or mention random and try executing.
c. Streaming Connection: Select this check box, as we are sending the streaming data.
d. Request Data: Example: 2probe. Imitate what all the requests needed to establish the web socket connection.
e. Web Socket Response Pattern : Don’t ever forget to mention this pattern (.*). If any one know any other pattern please let me know.
f. Close Connection Pattern : (6:::*) I mentioned these pattern only by trail and error method. If any body knows please let me know.
g. Message Backlog: Mention 1000.
h. Path: Here, In the browser transport=polling, have been replaced as transport=websocket.
























































12 The Web Socket remains the connection open for next requests. We can send other requests using this connection open.

11 comments:

  1. Hi Pradeep- Is it possible to add more screenshots of the steps for the above example ? I mean any pre-processor you used or x path generator etc...

    ReplyDelete
  2. Hi,

    I tried the above steps as it is but not able to connect with the web socket, it is showing me error, please suggest what to do regarding this?

    ReplyDelete
  3. Hi,

    http://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-server/9.1.1.v20140108
    http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-io/9.1.1.v20140108
    http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util/9.1.1.v20140108
    http://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-api/9.1.1.v20140108
    http://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-client/9.1.1.v20140108
    http://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-common/9.1.1.v20140108

    Download jar files from above urls and place it in
    apache-jmeter-2.13\bin

    ReplyDelete
  4. can any one please tell me that my websocket sample options are entirely different with the above screen shots, and i am getting "Response message: java.io.IOException: Incomplete handshake response".

    please help me, any response will be highly appreciable.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. First upgrade jmeter to latest version 3.0 or higher and then import jar file as mentioned in https://www.redline13.com/blog/2016/01/cloud-based-jmeter-websocket-testing/
    You wont see any errors

    ReplyDelete
  7. Hi Vishva,

    I am testing Websocket using jmeter. I was able to setup everything in my test but I am unable to close the websocket. I have given Websocket response pattern as - .* and close conenction patter as - 6:::*
    I see [Execution Flow]
    - Reusing exising connection
    - Waiting for messages for 1000 MILLISECONDS
    - Leaving streaming connection open

    Can anyone let me know how to close websocket connection?

    ReplyDelete
  8. is there a way to receive multiple messages on sent one request and apply assertion on the same?

    ReplyDelete
  9. is there a way to receive multiple messages on sent one request and apply assertion on the same?

    ReplyDelete
  10. Hello,

    There is a problem with this plugin. If on the second sampler reuse connection is checked, the response pattern of the second sampler is ignored.

    This is the issue : https://github.com/maciejzaleski/JMeter-WebSocketSampler/issues/19

    Does anybody know how to overcome this behaviour?

    ReplyDelete

Total Pageviews