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.

Total Pageviews