Hi everyone.
the problem i face is the following.
GIVEN i open a web-socket connection
WHEN the conection is just opened
THEN i receive 4 different messages at once(with some miliseconds interval)
i want to read all messages, but whatever i do, only the first message is being read.
It seems that you will need to wait for Gatling 3.11 to be able to use the new ws.processUnmatchedMessages action.
Sample of future usage:
exec(
// store the unmatched messages in the Session
ws.processUnmatchedMessages((messages, session) -> session.set("messages", messages))
);
exec(
// collect the last text message and store it in the Session
ws.processUnmatchedMessages(
(messages, session) -> {
Collections.reverse(messages);
String lastTextMessage =
messages.stream()
.filter(m -> m instanceof io.gatling.http.action.ws.WsInboundMessage.Text)
.map(m -> ((io.gatling.http.action.ws.WsInboundMessage.Text) m).message())
.findFirst()
.orElse(null);
if (lastTextMessage != null) {
return session.set("lastTextMessage", lastTextMessage);
} else {
return session;
}
})
);
@sbrevet Thanks for fast response.
Just to double-check and be on the same page I will describe the issue one more time and wait for confirmation.
In the screenshot you see 4 messages received at the same time as soon as the websocket is connected:
what try to do, is to fetch some data from the second message, or third or fourth one.
But whatever I do, I am able to reach only the first message and that’s all.
A small piece of code where I try to receive the second message but its failing.
So you suggest waiting for 3.11 in order to handle it?
Thanks again
Indeed, it is the way I think this new action will work: as your messages arrive at connection, you may want to pause a short amount of time before processing all messages in the meantime, so you will be able to manipulate them as your wish.
Yes, because I don’t see a satisfying workaround for now.
If you know that you’ll be expected exactly 4 messages and the order is predefined, this is already something you can achieve with Gatling 3.10.
Please check the documentation: Gatling WebSocket protocol reference
@sbrevet@slandelle
Thanks for all responses, i was not able to resolve the issue.
From the screenshot, you can see that all messages are being received almost at the same time, and I guess that’s why I can interact only with the first one.
I think while the code is being executed all other messages are already being received.
in short- I can catch only the first message, and the one that is empty (that comes with mode delay)
Is there a timeline when 3.11 version will be available, I think this is the only way to resolve my issue.