Search code examples
websocketjmeterasp.net-core-signalr

JMeter WebSocket plugin - Close SignalR connection


I've a website using Asp.NET Core SignalR to dynamically load data from the server.

I use JMeter to do functional tests on this page. I use the WebSocket sampler plugin in version 1.2.1 to test the SignalR functionality.

Following this blazemeter tutorial on how to use JMeter with the WebSocket sampler plugin I get always an error when trying to close the SignalR connection.

My JMeter sampler setup looks like:

  1. WebSocket Open Connection
  2. WebSocket request-response Sampler
  3. WebSocket Single Read Sampler
  4. WebSocket Close

For closing the connection I use the WebSocket sampler called WebSocket Close. This sampler allows to provide a Close status.

I've tried to provide different Close status codes. But non of the provided codes actually got confirmed and always the error message was returned:

Response code: WebSocket error: unsuccesful close.

Response message: WebSocket error: received not a close frame, but Text frame with text ...

How can I properly close this connection in JMeter?


Update

I've figured out that it depends on how many samplers I use. If I use a write sampler before the read sampler the close seems to work. Like:

  1. WebSocket Open Connection
  2. WebSocket request-response Sampler
  3. WebSocket Single Read Sampler
  4. WebSocket Single Write Sampler
  5. WebSocket Close

But if I want to have more then one read sampler it doesn't work. Any idea how I properly use multiple read sampler?


Update 2

I've re-read the Plugins documentation and also checked the sample JMeter files here. Unfortunately I haven't found a bigger sample with multiple Read Samplers so far.


Solution

  • What probably is happening is that your server has sent some text messages that your JMeter test script hasn't read. These messages are buffered and when you close the WebSocket connection, the "Close Sampler" first reads one of those text messages and returns an error.

    There is a change request for enhancing the "Close Sampler" with an option to ignore such bufferend messages. For the time being, you can achieve the same by combining a text frame filter with the close sampler; see the "Smart close with filter sample.jmx" sample in the samples directory.