How to manually add WebSocket Header in Jmeter? - websocket

I am using jmeter plugin (WebSocket Samplers by Peter Doornbosch) for creating websocket requests manually.
Opening the connection to websocket
I use "Websocket Open Connection" sampler.
Fill all details (server,port,path)
The connection also requires sessionID.
I tried http header manager but it doesn't takes up the header while execution.
SO, is there a way to manually add websocket header to the (Websocket open connection) sampler?

Http Header Manager is the way to go; the sampler picks up all the headers, except the ones that are used by the WebSocket or HTTP protocol itself (e.g. "Host", "Sec-WebSocket-Key"). If your header is called "sessionID", it definitely should work. See also the "Basic request-response sample with Header and Cookie Manager.jmx" example in the samples directory (https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/master/samples/)
Are you 100% sure the sampler did not include the header? Did you check the HTTP GET request with a tool like WireShark?

Related

How to pass request headers to the web socket request response sampler

I receive some response headers:
Connection: Upgrade
Sec-WebSocket-Accept: zi1DDwu1UMCCUC1nJX/k65L6jfQ=
Upgrade: websocket
as a result of web socket open connection
response header of websocket open connectiob
and now need to pass it to the request headers of the request response sampler as right now in the above image
request header of response sampler
there are no request headers shown
but for HTTP request it is coming (check for request header of HTTP request
I tried passing the values to the header manager but it is not passing to websocket sampler they are passing for only HTTP request.
I want that request headers to be passed to the web socket request response sampler
You don't need to do anything.
The WebSocket Samplers plugin by Peter Doornbosch automatically handles Sec-WebSocket-Key and Sec-WebSocket-Accept headers, moreover it even checks that the latter one has its anticipated value.
You can see the outgoing headers by either using a sniffer tool like Fiddler or Wireshark or enabling debug logging for the WebSocket Samplers plugin by adding the next line to log4j2.xml file:
<Logger name="eu.luminis" level="debug" />
JMeter restart will be required to pick up the change, once done you will be able to see request and response details in jmeter.log file

JMeter - websocket plugin - forbidden error

We are trying to test a WebSocket communication using the JMeter plugin(WebSocket request-response Sampler) by Peter Doornbosch. Headers are sent appropriately, response headers are received as intended with Response code:101. But the message says {"message": "Forbidden", "connectionId":"xxxxxxxx=", "requestId":"xxxxxxxx="}.
"Headers are sent appropriately" - I doubt this is the case.
Compare requests which are being sent by JMeter and by the real browser (or other WebSocket client application) using an external sniffer tool like Fiddler or Wireshark - the requests must be exactly the same (apart from dynamic values which need to be correlated).
Given you will be sending the same request with JMeter as the real browser does you will be getting the same response
Also it might be the case of missing authentication/authorization token which is normally being added to the URL

Possible if want to do API Load Testing using JMeter with URI info only?

My team planned to do API Performance Testing using JMeter 5.0 for my client. My client developed the API in Kubernetes. Just wondering, they gave info such as URI, HTTP Method and Content-Type only. We never have experience using URI. Are these info sufficient to do load test in JMeter? And where do I fill in these info? Is it in Config Element: HTTP Header Manager?
Because usually I only do my enablement using sample website which already provide the URL.
Do I need to ask them to provide the specific URL for this? Or URL can be extracted from URI?
Thanks.
Normally you should put:
Protocol, server name or IP and Port Number into HTTP Request Defaults, this way you will have a single configuration element having these details and in case of change you will need to introduce the change at one place only and won't have to revisit each and every HTTP Request sampler
Individual requests are defined using individual HTTP Request samplers where you need to provide URL Path and request body (if any)
Content-Type and other Headers can be provided via HTTP Header Manager, the same Scoping Rules as for HTTP Request Defaults apply, for example if you want to send application/json for all the requests just add HTTP Header Manager on the top of your Test Plan and it will add the header to all HTTP Request samplers which are at the same level as the HTTP Header Manager or lower.

How to add parameters to Websocket requests in JMeter?

How to add the below details to the WebSocket Open connection? (please check the links below)
Is my understanding right - The details in the above Screenshots are to be added to WebSocket Open connection. Following which I can have WebSocket request-response Sampler using the same connection.
Some headers like Sec-WebSocket-Key and Upgrade are being added by the Java
code, you can take a look at WebSocketClient.java file to see which and how. For the others - WebSocket Samplers respect HTTP Header Manager
With regards to request parameters - just add them to the "Path" section
For the headers - they will be added as per Scoping Rules, for the Path - if you decide to use existing connection - it will be propagated

How to wait until receiving multiple websocket responses send in sequence, for a single request sent, using JMeter

I am using the Jmeter WebSocket Sampler. I have successfully connected to the websocket, and can send a json request. It is a chat bot, and I will be validating it's response.
However, I have observed in websocket log, the websocket responds to the json request with a short confirmation response before the actual response.
for example, the first response is {"event":joingame,} where the response is {"event":"game"}. I don't really need this information.
Only then is the real response sent (as I observed in webscoket log)
I have tried the general Websocket Sampler.
The websocket responses come in "frames", each having a JSON response, my samplers are closing right after the first frame.
You might want to switch to the WebSocket Samplers by Peter Doornbosch which can be installed using JMeter Plugins Manager
This way you will be able to establish a connection first:
and then continue reading the frames re-using the connection unless you find the frame with the content you're looking for:
It makes sense to use JSON Extractor and While Controller in order to continue reading until the anticipated text appears in the response.
More information: JMeter WebSocket Samplers - A Practical Guide

Resources