Unable to connect to webrtc server from jmeter - jmeter

I am trying to load test WebRTC server using JMeter.
The wss URL works fine in browser, but in JMeter it is returning 400 error in WebSocketOpenConnection.
URL that I am trying to hit is :
wss://myserver Port 3004 Path socket.io/?userId=K&EIO=3&transport=websocket
Same URL is opening properly in Chrome.
JMeter logs:
2022-09-08 16:27:53,195 ERROR e.l.w.WebSocketClient: Ignoring user supplied header 'Connection=Upgrade' 2022-09-08 16:27:53,195 ERROR e.l.w.WebSocketClient: Ignoring user supplied header 'Upgrade=websocket' 2022-09-08 16:27:54,320 ERROR e.l.j.w.PingPongSampler: Sampler 'WebSocket Ping/Pong': there is no connection to re-use
Any idea what am I missing?
Thanks

If you have only one WebSocketOpenConnection sampler in your Test Plan that explains a lot.
Your JMeter test must represent a real user opening a real browser and accessing your web application with 100% accuracy and as a real user using a real browser you first should send a HTTP GET request to the page mainly to get some cookies which may be required for successful establishing of the WebSocket connection.
Once done you need to implement protocol upgrade mechanism to create the session.
And only then you should try to open a WebSocket connection and start sending and/or receiving messages/frames.
So you need to create the same network footprint as your browser (or other application) does and then the request will be successful. And don't forget about correlation of the dynamic parameters as this K&EIO user ID seems to be something generated.

Related

jmeter and Cloudflare : 1020 error ; works with Postman

New to Jmeter so I am not sure if my set-up is correct.
Basically I have these set of API's that I need to Perf test. Starting with a setting up a basic connection from Jmeter - I am receiving 1020 error from cloudflare
Access denied | "domain" used Cloudflare to restrict access
and
<div class="cf-alert cf-alert-error cf-cookie-error hidden" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
It works with POSTMAN. So wondering what changes I'll need in jmeter.
I have enabled save cookie in jmeter.properties file
API is for logging into a portal: verified username/password. VPN connection verified as this works from postman.
If you're absolutely sure that the request works in postman (although I'm getting this 1020 error even with the real browser) you should be able to get the same behavior in JMeter as well, just make sure to send the identical request (pay attention to HTTP Headers as well)
The easiest is just recording your Postman request using JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy
and run your request - JMeter will generate appropriate HTTP Request sampler and HTTP Header Manager
If you need to use VPN for proper access you might need to configure source IP address at the "Advanced" tab of the HTTP Request sampler like it's described in Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter article
In any case load testing an API behind Cloudflare might be not the best idea as Cloudflare provides DDoS protection and may (and will) block this type of traffic so you need to either whitelist your IP address(es) or let them know about your load testing activities, I believe they will be able to suggest a better workaround than anyone here
This is related with the securities features of CloudFare, either DDos protection or bot blocking. Exceptions can be configured from the CloudFare control panel.
If you don't have access to this panel you'll have to ask the corresponding person inside your company tasked with this job.

Error while trying to send the message over websocket connection in Jmeter | WebSocket Samplers by Peter Doornbosch

I am using a plugin (WebSocket Samplers by Peter Doornbosch) to establish the WebSocket connection in JMeter and trying to send the request message over it but receiving below error in logs
ERROR - eu.luminis.jmeter.wssampler.RequestResponseWebSocketSampler: Unexpected frame type received in sampler 'WebSocket request-response Sampler': Close frame with status code null and close reason 'null'
My test plan consists of "WebSocket Open Connection", "Web-socket request-response sampler" and "web-socket ping/pong frame filter". And I feel there is no issue in establishing the connection but something is wrong while sending the request or receiving a response.
Also, tried checking the logs from the server but didn't find any requests which were sent using JMeter.
Implemented another available plugin too in Jmeter to test the WebSocket but seeing similar behavior. Any help would be highly appreciated.
It looks like you're using the wrong sampler type, looking into the error you're getting it makes more sense to use single-write sampler which is designed for sending one (text or binary) WebSocket frame.
You might want to use a sniffer tool like Fiddler or Wireshark to capture the traffic between your browser (or application) and the backend and see what types of frames are going, which direction, is single connection re-used or each time new one is established, etc.
You may also find the following links useful:
Example scripts collection
JMeter WebSocket Samplers - A Practical Guide
The problem is that your server is actively closing the connection. Usually, this is caused by the client sending a request that the server does not understand. In your case, it's very likely that the request you are sending in the request-response sampler is not accepted by the server. As Dmitri suggests, the best way to find out how a "normal" client communicates with the server is to capture a session with WireShark and model your testplan accordingly.
Hth.

500 Internal Server Error In Load Testing By Jmeter for SAP application

I am writing load test script for an SAP-based application in jmeter. I am getting 500 internal Server.
I saw that the request looks same which I have on the browser network tab and the one I provided in JMeter. The only difference is in the request header, that I am not providing any SAP-passport in my request. I am not to see the SAP-Passport in the response of any previous request's response so that I can extract that and use in future requests.
Please tell me if I am assuming correctly that the SAP-Passport is the issue, if yes then how can I get that and use in the request. Also if there is a way to get any static SAP-Passport.
Its a blocker for me and its on priority, please help.
As far as I can see from Single Sign-On with SAP Passports article it is a matter of adding a client certificate to JMeter.
Obtain SAP Passport root certificate somehow (i.e. export it from your browser)
Add it to JMeter. This can be done in 2 ways:
Using SSL Manager
Using JMeter system.properties file
Check out How to Set Your JMeter Load Test to Use Client Side Certificates guide for comprehensive instructions on both approaches.

JMeter API Testing - Recording the Incoming Traffic

Using JMeter, the HTTP Request is hitting a URL with the port.
Eg : apitesting.com:8888/api/series/one
I have also added a HTTP Test Script Recorder in JMeter, where I can mention the port and domain.
How do I import the incoming traffic to JMeter using tcpreplay and JMeter Proxy for the above example.
Thanks for your help in Advance.
Have you read the FAQ?
Does tcpreplay support sending traffic to a server?
If by server you mean a daemon (Unix) or service (Windows) which listens on a port (a web or mail server would be common examples), then probably not. The biggest issue is that tcpreplay doesn't understand the state of common protocols like TCP. This means it is unable to synchronize Syn/Ack's to create valid TCP sessions.
So you have the following options:
Consider using Wireplay tool instead
Convert your .pcap file into JMeter .jmx script using BlazeMeter JMX Converter
In both cases be aware that you will get only a "skeleton" of the project, you won't be able to replay production traffic, all you will get would be a set of HTTP Request samplers, you will have to figure out the workload model on your own.
In JMeter you can add to your HTTP request a Post Processor Named Response Assertion, If you check the Ignore Status checkbox you will ignore response of the server so even if server is down it'll not fail test and continue.

Internet access via browser

Is it possible to use browser's internet connection for other application?
I'm in environment where browser is the only application that may access internet connection. Meanwhile, I need to run maven projects which needs internet access to download the required JARs.
I was thinking about creating Proxy Server in Chrome extensions or other browser. But, I hope I can find another easier way.
Sounds like Selenium WebDriver is what you need. You could try to redirect the download to browser or try to programmatically simulate browser.
Yes it is possible.
Recently I created a http_proxy server in Java which start 3 socket servers:
Http server to receive user request, and
WebSocket server to allow Chromium extension to create connection to the http_proxy server.
Http Server to receive response body from Chromium.
So, there will be 3 socket connections:
To receive http user request and send back the content, and
To send the URL requested to Chromium browser
When response received by browser (via Xhr), it will do HTTP POST to http_proxy server to send the content.
That's all!

Resources