Websocket heartbeats as an asynchronous task


In my Gatling scenario when a user logs in, a websocket connection opens.

To maintain the connection I have to ping the server every X ms, otherwise the connection crash.

My need is to execute a loop where the heartbeat between websocket client and server is executed at the same time as the scenario.
Is there a way to execute some action as an asynchronous task inside a Gatling scenario with Gatling DSL or Scala ?

Thank you in advance.


Nope, you’ll have to make those messages parts of your flow.

On the website I want to test, the heartbeat is running in the background until the user disconnected.

So, I want to simulate that in my Gatling scenario and this translate into a loop that run until the user logs out. The problem is that block the flow of the scenario...

There is no way to simulate this behaviour ? Even with some Scala code ?

I don't know if my explanation are clear...


I had the same problem. I did not find the way to integrate heartbeats into the main test flow unfortunately.
The only way i found to deal with it was creating my own version of wsActor, which sent a heartbeat on every heartbeat coming from server side. But it was in Gatling 2.3. I did not have time to migrate to Gatling 3 yet, but it might be possible to implement something similar there.

Hi Stephane,
Can you please give an example of how we can do this?

In gatling 2.3.1 ping/pong was taken care by the framework.

Thanks in advance.