Websocket Single Write 'Use existing connection' with specified Path

Issue #203 new
Dennis Dahler created an issue

I am testing a socket-based web application . The approach taken by our Dev team is to call an API which opens a connection via wss with a Server name and Path. The Path contains a server instance value and an access token which specifies the user connecting to application running the socket server. The typical Use Case is for multiple users to connect to the socket server via different browsers and each has the level of access afforded by their access token.

I am trying to simulate two users having this application ‘discussion’ via two socket connections to a server and using one computer to run the script to handle the interactions between the users. In JMeter I open two sockets to the server as different users (Say, Users A and B). I call two WebSocket Open Connection Samplers using the access tokens in the Path to differentiate between the two users. As long as all of the interactions are made by User A via WebSocket Single Write Sampler, everything works as expected. My issue is once User B attempts to write to its socket instance, within the first few Writes the threads start returning non-200 Response Codes and both User A and User B are disconnected by the server. At that point our application breaks and the socket server restarts itself to recover and the JMeter script fails while that is happening.

If I connect only as User A and use WebSocket Single Write Sampler to write to the socket multiple times, then connect to the server as User B and write to the socket multiple times, the script runs as expected. The issue seems to be maintaining two separate concurrent Websocket connections for two separate users on the same computer. The WebSocket Single Write Sampler allows me to ‘use existing connection’ or ‘setup new connection’. It is only by selecting ‘setup new connection’ where I can specify the Path which contains the access token for our user.

We would like to avoid creating a new socket connection each time the other User in the software ‘discussion’ must take action. It would be very nice to be able to have a third option in the Connection section ‘use existing connection with URL’ or ‘use existing connection with custom Path’ or something similar. The intent is to specify the Path on the existing connection call such that the access token embedded in the Path for the given user can be honored. Instead, when ‘user existing connection’ is selected the Path is grayed out.

Thanks for your time,

-Dennis

Comments (4)

  1. Dennis Dahler reporter

    Hi Peter,

    Thanks for foreseeing the need for something like this and responding so quickly. I am however not able to get the multiple-connections Websocket handling to to build for me. When I execute 'gradle assemble' I get this error and have not (yet) been able to get past it. (Disclaimer: I am a Gradle/Maven N00b.) I am using the default build.gradle file supplied in the project. (I have also tried building using some other plug-ins for maven flavors from gradle.org but no joy.)

    C:\Projects\jmeter-websocket-samplers>gradle assemble

    FAILURE: Build failed with an exception. * Where: Build file 'C:\Projects\jmeter-websocket-samplers\build.gradle' line: 3 * What went wrong: A problem occurred evaluating root project 'JMeterWebSocketSamplers'.

    I have tried building using the gradle wrapper which displays the error:

    C:\Projects\jmeter-websocket-samplers>gradlew assemble FAILURE: Build failed with an exception. * What went wrong: Could not determine java version from '15.0.1'.

    My versions are these in case they are helpful. Gradle:

    C:\Projects\jmeter-websocket-samplers>gradle --v

  2. Dennis Dahler reporter

    Hi Peter,

    I was able to get the samplers to build successfully using the default files. I set up a clean Windows 10 VM with no taint of my other build tools, installed JDK 8.u291, and built successfully using the gradle wrapper as described.

    best regards,

  3. Dennis Dahler reporter

    Hi Peter,

    I just wanted to follow up to say that the multiple-connections websocket code was exactly what I needed. After building and applying the JAR files, JMeter was able to successfully maintain and navigate through the four separate Websocket connections we needed for our application from within the same JMeter thread. No undesired characteristics were observed. I will be thrilled to see that fix merged into the main application branch when you are ready to release it formally.

    thanks, and Best Regards,

  4. Log in to comment