How can i get messages from Signalr using Jmeter? - websocket

I want to automate REST API using Jmeter. My requirement is trigger and validate the signals generated from the field.Messages from the field like "communication lost" need to check whether this message reached API or not.These messages are developed using "signalr".Can anyone tell me how can i get the messages from signalr in Jmeter.

As per SignalR main page:
ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers.
So my expectation is that you can use WebSocket Sampler plugin in order to test this functionality. The plugin can be installed using JMeter Plugins Manager, check out WebSocket Testing With Apache JMeter article for comprehensive information on installation, configuration and usage of the plugin for WebSockets load testing.

Related

Multiple Parallel Websocket connections to SignalR hub in JMeter

We are trying to load test our login workflow, by simulating 50+ users logging into our front-end, via the API calls. As part of the login process, we make a websocket connection to a SignalR hub(Connect). We then send a call over the websocket connection to a custom endpoint in SignalR(Login), used to add some data to the Redis cache, then do some stuff which isn't important, then send a call to a different custom endpoint over the websocket connection(Logoff) and then Disconnect the websocket connection.
So my question is multi-part:
How do we create a websocket connection from within JMeter?
How do we make a call to a custom endpoint over the websocket connection in JMeter
How do we do this for multi users simulated to be running in parallel, so we can test the load? In other words, we need multiple websocket connections open / alive from JMeter so we can test the load.
Note: Please be aware, I'm asking this on behalf of the load tester/JMeter developer, but because they are new to Stack Overflow, and I understand the SignalR side, I've been asked to log it. I know zip about JMeter, so please handle me like a noob trying to help someone solve a frustrating but important problem.
JMeter per se doesn't support WebSockets, you will need a special plugin if you want to enable this functionality.
The most advanced, comprehensive and supported as of now is JMeter WebSocket Samplers by Peter Doornbosch, it can be installed using JMeter Plugins Manager
Once you install the plugin and restart JMeter you will see several new samplers which will allow to open connection, send request, read response, and close connection.
Unfortunately I cannot guide you further because I don't know the specifics of your application, just look into your browser developer tools or other sniffer tool and configure JMeter to send the same requests as your browser (or other application) does.
More information:
Test SignalR Performance with JMeter
JMeter WebSocket Samplers - A Practical Guide
samples directory contains several example test plans covering different scenarios

Load Testing couchbase server - Unable to capture calls triggered from couchbase lite to sync_gateway

Our mobile app uses couchbase lite (version 2.7) and it replicates the data to couchbase server through sync_gateway. Now we want to capture the calls being triggered from couchbaseLite to the sync_gateway. we need to capture these calls because we want to simulate these calls in our load testing tool and load test the sync_gateway directly from our load test tool.
we tried using charles proxy to capture these requests, but however we are not able to capture the replication requests. Only request i could capture is _blipsync call (and that too in websocket format).
I understand that couchbaseLite 2.7 talks to sync gateway in websocket layer. But is there a way i can capture the requests triggered from couchbase lite to the sync_gateway for push/pull replications?
You can use the cblite CLI tool for simulating a Couchbase Lite client. You can launch a number of instances of the client, preferably on a beefy cloud instance that you can scale up to handle a large number of clients. The tool also includes a mini HTTP listener that allows you to interact with the tool via a REST API.
Another Java based client that you can use for simulating a client is available here and a blog goes along with it.

Should I use web sockets to pull data from server or just a flag and use that flag to send API request for data?

I am working on a project which is basically a Customer Feedback Analysis Dashboard. There are few graphs on the dashboard and data for each graph is fetched from the server through API requests.
Right now the dashboard is updated every time the page is refreshed. I want it to be updated immediately when there is a new feedback in the system. I am confused, whether I use websockets to send data for each graph or just a flag and use that flag to fetch data through API requests.
Like, facebook/twitter does. They tell you about new posts/tweets and when you click that button your feed/wall gets updated.
If you want to "push" data from server to client and you want that data to show up in a timely fashion (e.g. within 10-20 seconds of when it was available on the server), then you will want to implement some sort of "push" solution where the server can efficiently push data to the client whenever there is new data to send.
There are several possible approaches:
webSockets
socket.io
Server-sent events
Mobile platform-specific push (Android and iOS)
For a general purpose solution that works within a browser, you will want to use one of the first three. socket.io is built on top of webSockets (it just adds more features) so architecturally, they are similar.
Server-sent events are fairly new (modern browsers only) and are only for one way communication (from server to client). webSockets can be used for communication either way.
I'd personally recommend socket.io because of the features it offers (such as automatic client reconnection) and a simplified messaging layer. You can see the feature difference between socket.io and webSockets here. With socket.io, the client makes a connection to the server when the web page is loaded and that connection is persistent. After the connection is established, then either client or server can send messages to the other at any time in a very efficient manner.
Other useful references:
Push notification | is websocket mandatory?
websocket vs rest API for real time data?
Why to use websocket and what is the advantage of using it?
What are the pitfalls of using Websockets in place of RESTful HTTP?
Ajax vs Socket.io

Stress testing WebSockets in Jmeter

I'm trying to stress test my WebSocket server using Jmeter's plugin (jmeter-websocket). The thing is that the plugin comes with no documentation how to work with it and thus I'm not sure if my expectations of it is supported or not.
I managed to run a sample test using the mentioned plugin and it was successfully connected to server. It also managed to communicate with server but once it was done receiving the first response it disconnected. I was hoping to configure this plugin in a way so it will maintain a persistent connection with WebSocket server for several minutes, sending and receiving a couple of messages before it is disconnected.
By stress testing I would like to see how the number of concurrent connections affect my application's behavior. Is this plugin suitable for my needs? If it is then how should I work with it?
I had exactly the same problem. the plugin you have mentioned worked only for a HTTP-like request/response but I couldn't use it for a "long" connection.
Have a look at this http://github.com/maciejzaleski/JMeter
Features:
Supports HTTS/HTTPS (ws/wss) version of the WebSocket protocol
Option to ignore SSL certificate errors
Streaming allows for a single connection to remain open for the duration of the test
Response has to match predefined regular expression
Response timeout
Response message backlog (build the Sampler response from multiple server messages)
Connection could be closed if server sends a message matching predefined regular expression
As of November 2017, the best Websocket Sampler for Apache JMeter is this 3rd party plugin:
https://bitbucket.org/pjtr/jmeter-websocket-samplers
It can easily be installed through jmeter-plugins plugin manager.

Asynchronous messaging (ActiveMQ, MSMQ) to ASP application (MVC3)

I have been reading articles about asynchronous messaging between clients using MVC3 and the SignalR library (http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/)
We currently use activemq for some of our fat client apps and use topics to broadcast data to everyone. Does anyone know if this sort of thing could be used in MVC3 as well?
I'd like to create an application that doesn't require a user to install anything (and could even be used on a phone), but it would be monitoring continuously-changing data. We're talking refreshing data every 2-3 seconds.
If you want to have asynchronous messaging with client (browser) use SignalR. ActiveMQ and MSMQ are technologies for thick clients and server-to-server communication. They require installation (MSMQ requires windows installation) and they are not accessible from browser (well I can imagine accessing MSMQ through ActiveX or ActiveMQ from Java applet but that is not what you are looking for).
One of the possible ways to go is to build a web service which will implement communication with AMQ/MSMQ via their APIs and do poll this web service from your webpage (via ajax call for example) to refresh the data as it's needed.

Resources