ClientProtocolException in jmeter - testing

I am new to testing and using the jmeter for the first time. Using these steps I am trying to record the mobile device scripts in jmeter. I have done the following steps:
Open JMeter and right-click the TestPlan>Add >Threads (Users)>Thread Group.
Right-click the Thread group>Add>Logic Controller>Recording Controller.
Right-click the Threads>Add>Listener>View Results Tree.
Add test script recorder by selecting Add>Non-Test Elements>HTTP(S) Test Script Recorder option.
Add ‘8080’ as Port value and click the Start button. This will start the JMeter proxy on localhost.
but when I am checking the server status on browsers (https://localhost:8080), following error comes:
org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: https:////
at org.apache.http.impl.client.AbstractHttpClient.determineTarget(AbstractHttpClient.java:817)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:517)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:331)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:240)

You shouldn't be opening https://localhost:8080 URL in browser, you need to configure your mobile device to use the machine, where JMeter is running as proxy host and 8080 as a proxy port.
If you want to test the HTTP(S) Test Script Recorder - configure you browser to use localhost as a proxy host and 8080 as a proxy port and open some intranet or Internet page - you should see the requests under the Recording Controller.
You quickly set up JMeter for recording using Templates feature, just choose File -> Templates -> Recording -> Create from JMeter's main menu and you will have JMeter ready for recording in a couple of seconds (default proxy port will be 8888 in this setup)
If you are targeting to record HTTPS traffic on a mobile device you will also need to install JMeter's self-signed certificate onto it. Look for ApacheJMeterTemporaryRootCA.crt file in JMeter's bin folder, send it to yourself via the email, open the email on mobile device and follow your mobile OS dialog to get it installed.
See Load Testing Mobile Apps Made Easy guide for more information on proper recording of mobile devices traffic using JMeter

Related

debugging chrome remotely - doesn't open websocket

Im running chrome headless through chromedriver and selenium via python.
I've run into the following issue both on Mac and Linux.
Im starting chrome as follows:
if self.headless:
options.headless = True
options.add_argument("--headless")
if self.debug_port:
logging.info(f"Setting up remote debugging on port {self.debug_port}")
options.add_argument(f"--remote-debugging-port={self.debug_port}")
options.add_argument(f"--remote-debugging-address=0.0.0.0")
If I connect to http://localhost:9222 from another headed instance of chrome I can see the list of sessions and connect to it seamlessly. At which point i have a window opened up with a screencast of the remote session and the dev console.
Here's that successful example:
When I connect to http://192.168.1.194:9222 I get the list of sessions just fine and upon selecting one the dev console opens but it doesn't start the websocket connection to ws://192.168.1.194 so the screencast and remote debugging capabilities are not available.
Here's that failed example:
I've captured har files and uploaded them here if you want to take a look
Using the following steps I was able to debug remotely. However the screencast functionality did not work. Ultimately that's what I needed so this is only a 50% solution in my case.
So, as noted above in the comments, what's blocking remote debugging from working is that the chrome debugger links out to https://chrome-devtools-frontend.appspot.com/..... and passes a value of ws://192.168.1.194 for the websocket parameter. Any browser will inherently block this, based on it being mixed content - i.e: https + ws
What's needed here is to run the chrome dev tools frontend on a http server
and direct your chrome instance to that server instead of the appspot instance.
Solution Steps
1 Install depot_tools (pre-requisite for building)
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
2 Checkout the devtools-frontend repo
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#checking-out-source
3 Build chrome devtools frontend
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#build
4 Start the devtools-frontend http server
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#running-in-hosted-mode
5 Run 2 instances of chrome and use one to debug the other
5.1 Start first instance of chrome headless
...with remote debugging enabled. See the python way in the question above or do it from the command line with the same arguments
5.2 Start a second instance of chrome
...using a different user data dir --user-data-dir=<some-path>
5.3 Navigate to http://192.168.1.194:9222
Use whatever the IP address of the first chrome instance is and the port that you chose.
5.4 Create a link to the local dev server
The 2nd instance of chrome will now be showing you links to debug each of the open tabs of the 1st instance. However the links will still to go https://chrome-devtools-frontend.appspot.com/..... You'll need to copy n paste the link you want and replace the hostname with the hostname of the devtools frontend that you started in step 4
Walla!!
If you figure out how to get the screencast working please comment below! 🙏
N.B:
I also tried using the npm run server command in the devtools frontend but for some reason that server didn't work at all ¯\_(ツ)_/¯

Having trouble using my laptop as a proxy for my smartphone

I want to capture my smartphone network logs on jmeter. This usually requires that my smartphone accesses the internet through my laptop by using it as a proxy and making jmeter listen on the port through which the smart phone is connected. Here are a few references I found on the internet:
http://findnerd.com/list/view/-How-to-Connect-the-Android-Mobile-Device-to-JMETER/4929/
https://dzone.com/articles/how-to-record-mobile-appli-cation-traffic
There are others references but they essentially say the exact same thing. I followed all the steps but my smartphone is unable to access the Internet when I set its proxy to my laptop's IP address . The only difference could be that since the motherboard wifi adaptor had started malfunctioning sometime back, I am using a USB WiFi adaptor on my laptop. I need to know how to make this work and capture my smartphone network logs on my laptop using jmeter. Any help appreciated
UPDATE - Found the issue. I needed to install an SSL certificate on my Android phone. This certificate is generated by jmeter in it's bin folder. I had to send to to my Android device and install it. Now, I can access the internet on my phone through my browser and o am able to see the https traffic being recorded in JMETER. but, when I try to access any apps, it gives me the following error:
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown.
I know it has something to do with the self-signed certificate generated by Jmeter, but I am not sure why it's working for chrome and not for apps. Anybody know any solutions to this?
First of all you need to install JMeter's MITM certificate onto your Android phone, the file is called ApacheJMeterTemporaryRootCA.crt and it's being generated in "bin" folder of your JMeter installation when you start the HTTP(S) Test Script Recorder
If your phone is running Android 7 or higher you will need to take some extra steps in order to be able to capture your application traffic
Add the next line to the application section of your application manifest file:
android:networkSecurityConfig="#xml/network_security_config"
Create network_security_config.xml file under your application resources folder and put the following code inside:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
Compile and install your application in debug mode like:
gradlew installDebug
That's it, now you should be able to capture your application traffic using JMeter.
More information: Recording Using Android Devices

IE lan settings revert back when rpt open it during recording http proxy

I am beginning to use Rational Performance Tester to do some load/performance testing and I stuck at the first step - recording a script. I am using IE 11 and I am disabling internet by going to Internet Options>Content>Lan Settings. Then I try to open some website and it won't open - which is good (expected behaviour). Then I run my RPT to do the recording and the Internet options revert back and 'Automatic Configuration' check box get checked (unwanted behaviour). The HTTP proxy recorder say that it is accepting connection at (some number) port but open connections stay 0. The bytes in the recording window do not move with any click, thus nothing being recorded. Thanks in advance!
I have only tried it in IE 11. Don't have access to any other browser (company policy)
There is no coding required.
I expect open connections to move above 0
This issue was solved when I had admin rights to the machine and application - run IBM RPT as administrator. Thus I was able to record the http traffic and successfully play it back using the load agents.

steps for recording the selenium events on jmeter proxy

I am presently working on a project for which selenium scripts are prepared and i want my jmeter proxy should record the steps executed by selenium browser. I tried running selenium and jmeter proxy server on same port but while doing that proxy server of jmeter refuse to start on same port. I read somewhere that this is possible but i am not getting the steps needs to follow.
You should do the same what you will do for simple test recording through Jmeter proxy:
setup Jmeter HTTP Proxy Server;
start configured Jmeter Proxy;
configure and enable proxy settings in your test browser (used by selenium) to use Jmeter Proxy.
Then run your selenium tests as usual, via configured test browser - HTTP Proxy Server will record execution.
To exclude all the steps performed in the "selenium-server" window try to add the following to 'URL Patterns to Exclude' in HTTP Proxy Server settings:
^/selenium-server/.*
Useful point here is to separate recorded execution into different Thread Groups - e.g. separate Thread Group in Jmeter for each recorded selenium testcase.
Step-by-step guideline you may found here.
To tell the truth such the "re-recording" may appear not very useful and effective: JMeter is not a browser, and does not interpret the JavaScript in downloaded pages.
As per Jmeter wiki:
JMeter does not process Javascript or applets embedded in HTML pages.
JMeter can download the relevant resources (some embedded resources
are downloaded automatically if the correct options are set), but it
does not process the HTML and execute any Javascript functions.
If the page uses Javascript to build up a URL or submit a form, you
can use the Proxy Recording facility to create the necessary sampler.
If this is not possible, then manual inspection of the code may be
needed to determine what the Javascript is doing.
So if you need Jmeter possibilities to implement load/performance-testing based on existent Selenium functional scripts better for you then use run Selenium scripts from Jmeter.

how to test open graph on localhost

I've done a lot of research and haven't found a definitive answer to this. Is there anyway to test the open graph on localhost? I don't haven any issues using the graph api on locahost.
I've changed my website url in the app settings and have even tried setting up a domain in my hosts file but the debugger linter for open graph tries to use the actual domain instead of my localhost and when using locahost directly the linter completely fails connecting.
Does anybody have any workarounds for this?
Using a local proxy is the right solution. ngrok didn't work for me neither.
A similar tool that did work with facebook debugger is localtunnel ✅
npm install -g localtunnel
lt --port 8000
# or using npx without installing localtunnel
npx lt --port 8000
Generates a url that looks something like https://<random_hash>.localtunnel.me/. Using this url in facebook open graph debugger worked for me as of October 18th 2017. I only had to hit Fetch new scrape information button. 🍻
Cool thing about localtunnel is that you can easily host your own localtunnel server with github.com/localtunnel/server so if it ever stops working with localtunnel.me, you can run your own somewhere in the cloud ⛅
You can use ngrok to create a random public subdomain that routes to your local webserver very easily, even through NAT or firewalls.
Just download ngrok and run ./ngrok http 8080 (assuming 8080 is your local webserver http port).
This will create a random subdomain like http://38a84a97.ngrok.io/ that routes to your local webserver and that you can use with Facebook to test your open graph tags.
Its very simple to test Open Graph in any local environment using Chrome or Firefox using plugins. I have used one to quickly show in chrome how the Open Graph looks to the viewer to test results. Here is a quote of what it does.
This extension shows how people will see your site in the most popular
social networks This extension is for professionals who creates a
media content.
To check meta-information of your site or article just open it in a
Chrome and click extension's icon. Also you could add an URL manually.
Here is a direct link to the plugin (Chrome)
Firefox add-on
As a bit simpler approach you can use a browser extension like https://socialsharepreview.com/browser-extensions - which will show your Social Cards directly in the Browser (which of course might fail, if you wrongly didn't set them serverside :))
To test open graph (and Twitter cards) I also had to expose localhost (Docker) to Facebook and Twitter. I used Serveo
It works very well for this, no need to install anything as it works with ssh port forwarding.
$ ssh -R 80:localhost:3000 serveo.net
Then navigate to the url given, and there you go.
You have to setup a public domain which points to your public ip address.
Use dynes.org or a similar service and setup your router to forward your port 80.
There are several tools you can use for serving something up over your localhost, each with varying degrees of functionality.
I prefer (obviously) http://forwardhq.com
Other great options here: http://devblog.avdi.org/2012/04/27/http-forwarding-services-for-local-facebook-development/
If anyone is looking to preview the :og tags on while developing on subdomains (using lvh.me) in localhost. You can use https://serveo.net.
Simply use following command to forward your local server requests. No installation required.
ssh -R yoursubdomain.serveo.net:80:yoursubdomain.lvh.me:3000 serveo.net
you can put your desired port in place of 3000.
Reference: https://blog.aarvy.me/2019/09/20/expose-local-apps-having-subdomains-to-web/