Jmeter - Websocket plugin - unable to find solution to constantly read incoming messages - websocket

Good afternoon.
I have implemented websockets in my project using the plugin "WebSocket Samplers by Peter Doornbosch" in Jmeter.
So far the requirements were simply to send and receive some payload, or simply send and forget.
However I got a new requirement where the server will constantly send back websocket message to client at every 5 second interval.
Ex: I send ABC , XYZ, ABD at every 3 second interval and I need to read XYC, YTZ at every 5 second interval both should happen simultaneously
I'm unable to use Parallel Controller as each item within the controller is a separate thread and thus I will loose web socket connection for the second one.
Is there any way I can achieve this using some listeners or something.
Thanks for your response in advance

As per documentation:
Fragmentation
WebSocket messages may be fragmented into several frames. In such cases the first frame is an ordinary text or binary frame, but it will have the final bit cleared. The succeeding frames will be continuation frames (whether they are text or binary is inferred by the first frame) and the last continuation frame will have the final bit set. The plugin supports continuation frames, but as the plugin is frame-oriented, you'll have to read them yourself. In cases where the number of fragments is known beforehand, this is as easy as adding an extra WebSocketReadSampler for each continuation frame you expect. If the number of continuation frames is not known, you need to create a loop to read all the continuation frames. For this purpose, the plugin provides a new JMeter variable called websocket.last_frame_final that indicates whether the last frame read was final. This enables you to write a simple loop with a standard JMeter While Controller; use the expression ${__javaScript(! ${websocket.last_frame_final},)} as condition. With a JMeter If Controller, the condition can be simplified to ! ${websocket.last_frame_final} because that controller automatically interprets the condition as JavaScript. See the sample Read continuation frames.jmx test plan for examples of using the While or the If controller to read continuation frames.
If you are unsure whether continuation frames are sent by your server or how much, switch on debug logging: samplers reading a frame will log whether the received frame is a "normal" single frame, a non-final frame (i.e. 1st fragment), a continuation frame or a final continuation frame (last fragment).

Related

JMeter (An established connection was aborted by the software in your host machine)

I am testing JMeter on my site, I use debug and catch exception which close my socket, I don't understand the reason for that
error: Response code:Websocket I/O error
Response message:WebSocket I/O error: Программа на вашем хо�т-компьютере разорвала у�тановленное подключение
(it means "An established connection was aborted by the software in your host machine").
Screenshot
First of all it looks like you're getting multiple frames as the response to a single call, as per documentation:
Fragmentation
WebSocket messages may be fragmented into several frames. In such cases the first frame is an ordinary text or binary frame, but it will have the final bit cleared. The succeeding frames will be continuation frames (whether they are text or binary is inferred by the first frame) and the last continuation frame will have the final bit set. The plugin supports continuation frames, but as the plugin is frame-oriented, you'll have to read them yourself. In cases where the number of fragments is known beforehand, this is as easy as adding an extra WebSocketReadSampler for each continuation frame you expect. If the number of continuation frames is not known, you need to create a loop to read all the continuation frames. For this purpose, the plugin provides a new JMeter variable called websocket.last_frame_final that indicates whether the last frame read was final. This enables you to write a simple loop with a standard JMeter While Controller; use the expression ${__javaScript(! ${websocket.last_frame_final},)} as condition. With a JMeter If Controller, the condition can be simplified to ! ${websocket.last_frame_final} because that controller automatically interprets the condition as JavaScript. See the sample Read continuation frames.jmx test plan for examples of using the While or the If controller to read continuation frames.
If you are unsure whether continuation frames are sent by your server or how much, switch on debug logging: samplers reading a frame will log whether the received frame is a "normal" single frame, a non-final frame (i.e. 1st fragment), a continuation frame or a final continuation frame (last fragment).
If this is not the case, another possible reason I can think of is that something is terminating the websocket connection on your machine, I don't know what exactly, maybe a firewall or an antivirus or your corporate proxy server
Try opening inbound and outbound traffic for the java process, add it to your antivirus whitelist and ask around, maybe your network administrator can shed some light on it.
If you want to get some more troubleshooting information you can add the next line to JMeter's system.properties file:
javax.net.debug=all
and inspect JMeter's stdout to see if there is a clue there.
More information: Debugging SSL/TLS Connections

How to test N_As, N_Ar timeout parameters in CanTp protocol using CAPL script or or any other possible way?

As part of CanTp protocol related tests, I have been trying to test N_As and N_Ar timeout errors, where N_AsMax = 1000ms and N_ArMax = 1000ms.
Is it possible to create the N_As and N_Ar timeouts with CANalyzer and/or using CAPL?
It would be great help, if you can share a possible way to test these timing parameters using CANalyzer or CANoe.
CanTP is a protocol to extendend the maximum data length (in bytes) of any given CAN data frame over the traditional 8 bytes, please refer to ISO 15765-2. Here you can have Single Frames, or Multi-Frames, which are trains of related frames each one carrying a portion of the overall PDU. A flow control frame is sent, usually by the receiver, to address and instruct the transmitter on the protocol to be used for frame splitting.
According to docs,
N_Ar [is the] Time for transmission of the CAN frame (any N-PDU) on
the receiver side (see ISO 15765-2)
N_As [is the] Time for transmission of the CAN frame (any N-PDU) on
the sender side (see ISO 15765-2).
In addition, the following requirements are relevant:
[SWS_CanTp_00075] ⌈If the transmit confirmation is not received after
a maximum time (equal to N_As), the CanTp module shall act as if it
had received an unsuccessful transmission confirmation and any late
confirmation shall be ignored. The CanTp module shall cancel
(internally) the failed transmission. ⌋ ( )
[SWS_CanTp_00311] ⌈In case of N_Ar timeout occurrence (no confirmation
from CAN driver for any of the FC frame sent) the CanTp module shall
abort reception and notify the upper layer of this failure by calling
the indication function PduR_CanTpRxIndication() with the result
E_NOT_OK. ⌋ ( )
Coming back to your question:
Is it possible to create the N_As and N_Ar timeouts with CANalyzer and/or using CAPL?
Yes, by means of the osek_tp.dll file that you should have in your local CANoe install (I'm using CANoe v10.0). Examples on how to use it are well documented in the help document AN-IND-1-012_CAPL_Callback_Interface.pdf, again it should be distributed in your CANoe install folder.
According to that document,
Basically, the OSEK_TP.DLL implements fault injection functionality
that has to be enabled explicitly in order to prevent unintentional
usage. Once activated, it is possible to setup a specific fault on a
connection that is executed during the next data transfer.
I'd urge to give it a read, and refer to linked documentation as well. I hope this is pointing you in the rigth direction.
Additional info:
Transmitting data over ISO-TP in CANoe using CAPL

Jmeter Websocket: Wait for all frames in a response

I am using the Jmeter WebSocket Sampler. I have successfully connected to the websocket, and can send a text request. It is a chat bot, and I will be validating it's response.
However, I have observed in Fiddler, the websocket responds to the text request with a short confirmation response before the chat bot's response.
for example, the first response is {"ok":true, "replyto":1151810327491, "type":"ack"} where replyto is a message ID. I don't really need this information.
Only then is the real response sent (as I observed in Fiddler), the one I would actually like to read and put Assertions on.
I have tried Websocket request-response Sampler, Websocket Single Write Sampler (followed by a Single Read Sampler), and I have tried the general Websocket Sampler.
TL;DR: The websocket responses come in "frames", each having a JSON response, my samplers are closing right after the first frame.
If the server is sending frames you are not interested in, there are two possible solutions.
If you know in advance which frame you want to discard (e.g. the first that is received after sending a message), you can simply use a Single Read Sampler to read the message you want to discard and have a second Single Read Sampler read the "real" message.
If the sequence of messages is not that easy to predict, you can use a Frame Filter to discard the messages for you, so they don't show up in the (Read) Sampler. For example, configure a Text Frame Filter with condition "starts with text" and use the string '{"ok":true, "replyto":' as match value, this will discard all frames that start with that string. If this doesn't work because the message you are interested in start with the same string, you can create more complex conditions, even with regular expressions.

Websocket protocol continuation frame

I am trying to understand the websocket protocol https://www.rfc-editor.org/rfc/rfc6455
but do not understand what the continuation frame is. If I am making a websocket client, when would I expect a server to send this? When would I want to send it?
The above reference has very little information about what the continuation frame is or does, or how a client (or a server) should handle it.
From the protocol spec:
Opcode: 4 bits
Defines the interpretation of the "Payload data". If an unknown
opcode is received, the receiving endpoint MUST _Fail the
WebSocket Connection_. The following values are defined.
* %x0 denotes a continuation frame
This is one of only three references to the continuation frame, and it is not giving me a lot to go on.
Should I just ignore any frames with this opcode?
No, you must not ignore continuation frames. If you don't implement them, your WebSocket implementation will not conform to RFC6455. Continuation frames are for fragmented WebSocket messages. All frames but the first are called continuation frames. All but the first and last are called non-final continuation frames.

Resend frames of message without copy

Question:
Can I initialize a new message with part of another message without copying? Modifying the message in place to drop the first few frames would also work.
Scenario:
I'm using the ROUTER-REQ pattern for a load balancing implementation. The REQ end sends a message to the ROUTER which prepends the identity and delimiter frame to the message. After my application uses that first frame to push the identity of the worker into an idle list, it needs to forward the final frame(s) of the message onto a PUB socket. Those final frames may be very large, and after extracting that first identity frame, I no longer need the rest of the received message, only to forward it on. This seems like a good place for zero-copy; I just need to drop those first two frames which were inserted by the ROUTER.
I haven't tried, but I think you can, I would try it with
using zmq_msg_copy, according to the man page.
The implementation may choose not to physically copy the message
content, rather to share the underlying buffer between src and dest.
I don't know why the man page uses "may choose", looking into the code I think it does all the time.
Here when I'm talking about message I mean "message part". so when you create your multipart message, you just zero-copy the necessary parts (frames)
Which binding do you use?

Resources