Chaman Preet
Chaman Preet

Reputation: 1

How to handle SignalR application with longpolling mechanism for load testing using Jmeter

We need to load test an web application using SignalR in few components with transport mode as long polling. My script gets hang in connect step. Connect step is GET- /signalr/connect?transport=foreverFrame&clientProtocol=1.5&connectionToken=ZW6cj17pImmCjGGBQSQNy%2Bdiy7DKDUy4i4R1AE78c%2FTitzS6QgiPoX6fM3zBOrDK11hyx0QNEc92JM6bsLY19MCt5JjaYFgdTDVsbxfnRbkqKp6dpsl64BV1zI8Vu1X%2F&connectionData=%5B%7B%22name%22%3A%22mypreviewhub%22%7D%5D&tid=10&frameId=1

I have correlated following 2 parameters- 1) captured connection token from negotiate step and used in subsequent requests 2) used ${__time()} for timestamp as found in link- How to capture signalR connection string in Jmeter

Apart from these, I can see 2 more parameters being send in connect step- tid and frameid. Do we need to correlate these 2 parameters as well, although these are not used anywhere else apart from connect step?

Or what is that my script lacking?

In various posts, I have seen suggestions to use websocket sampler plugins but I believe that can be helpful, if your SignalR use websocket mechanism, not long polling.

Please help me resolve this issue. Your help is appreciated. Thanks

Upvotes: 0

Views: 1205

Answers (2)

Rohan Gordon
Rohan Gordon

Reputation: 1

This solution is for Load runner Users. 1.The tid does nor the frame id dosn't have to be parameterize. java script is randomly generated for TID FROM 1 to 11

  1. Your time stamp is 12 digit random number

  2. THE REASON FOR THE HANGING is that forever frame is an Asynchronous function of Signalr you must youse this statement to register a PUSH. If PUSH Doesnt work then do a POLL. lIKE SO

web_reg_async_attributes("ID=Push_0", "Pattern=Push", "URL=https://YOURurl.COM/signalr/connect?transport=foreverFrame&clientProtocol=1.5&connectionToken={CONNECTIONTOKEN}&connectionData=%5B%7B%22name%22%3A%22interactionhub%22%7D%5Dtid={TID}&frameId=1", "RequestCB=Push_0_RequestCB", "ResponseHeadersCB=Push_0_ResponseHeadersCB", "ResponseBodyBufferCB=Push_0_ResponseBodyBufferCB", "ResponseCB=Push_0_ResponseCB", LAST);

Then modify your callback.c function

int Push_0_ResponseBodyBufferCB( const char * aLastBufferStr, int aLastBufferLen, const char * aAccumulatedStr, int aAccumulatedLen, int aHttpStatusCode) {

//Enter your implementation for ResponseBodyBufferCB() here.

lr_vuser_status_message("This is accumulated String %s", aAccumulatedStr);
lr_vuser_status_message("This is response body %s", aLastBufferStr);

Use Asyn option enabled next time in your recordings and you will see this stuff, but you must close the browser window at the end of your recording else the Async stuff won't be released and created in your script !! I found this out using Fiddler.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168002

As per How does long-polling work? answer:

Case: The server does not have any information available for the client when the request (poll) is received.

Behavior: Instead of sending an empty response, the server holds the request open and waits for response information to become available. Once it does, the server immediately sends an HTTP/S response to the client, completing the open HTTP/S request.

So your "hanging" might indicate that there is no data coming from the server.

You might want to check out 5 Ways to Load Test Popular Chat Plugins with JMeter article which assumes using Parallel Controller for implementing Long Polling scenario test, it even has an example test plan

In any case your test needs to replicate what real browser is doing so I'd recommend capturing requests which are being sent by JMeter and the real browser using a sniffer tool like Wireshark and if there are differences - amend JMeter configuration so the requests would be 100% matching the ones, originating from the real browser

Upvotes: 0

Related Questions