Having trouble using my laptop as a proxy for my smartphone - ssl

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

Related

Can't use phone ase controller

I want to test my airconsole game on a smartphone before publishing. The problem is, I can't connect it to the simulator.
If i try to connect (Chrome on Android) it says connecting, after a few seconds it shows the enter code screen but no input is possible. After about 30 seconds I get the message download the app for next time. (Screenshots attached)
Do you know where the problem is?
My files are hosted on a webserver, accessible from everywhere.
Kind regards
Make sure your screen.html and controller.html are accessible from all devices.
Let's assume you are running your local web server on http://192.168.0.2:8080/
Try to access http://192.168.0.2:8080/screen.html and http://192.168.0.2:8080/controller.html using a normal web browser on the device that doesn't work. It should display the screen/controller html.
If you can't access http://192.168.0.2:8080/controller.html from your phone, but from your computer, make sure you are in the same network and that your router does not have "Client Isolation" activated.
If you are testing with real smartphones, make sure you do not use http://localhost/ or http://127.0.0.1/, because localhost is not your computer on the phone but the phone itself!
If you are still unable to connect your phone, you can use the ngrok tool to forward your local url. See our Ngrok Unity Guide for how to do this in the Unity Engine: https://developers.airconsole.com/#!/guides/unity-ngrok

Unable to connect with server while running react native app on real android device

I am trying to run my react native app on my real android device as the laptop gets too hot while using Android studio (8 Gb RAM, the pain). Hence, I enabled my USB debugging, plugged the cable and ran the command "react-native run-android". The app started with no issue. I started the backend server also which are up and running on localhost:3000 and localhost:3001. The app runs and greets with a login and sign up page. I tried to sign up but there is an error saying
Error [TypeError: Network request failed]
I am connecting via WIFI on the same network and hoping the server and the app can communicate but the app doesn't.
There is not any issue with the code itself as I ran it multiple times in android studio previously and the app ran well. I was able to sign up as a new user and login with the same id. I am not able to do the same in the real device.
My questions:
I read the official document and it said to open in-app developer menu and put the machine ip address and localhost server. Is this localhost server the one that the Metor JS runs on or the backend server of the app itself?
What am I missing here, any commands or any configuration?
Why is my app not able to communicate with the server?
Reason behind the network error.
You should follow these steps to connect with the bundler.
Make sure that the app and bundler using the same network.
If you are using android add this code in your androidMenifest.xml file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:usesCleartextTraffic="true" // make sure that this line is added.
.......>
.......
</application>
if you are adding localhost in the developer setting try to add your IP address like this, yourIP:yourPort
example: 192.168.89.24:8081

ClientProtocolException in jmeter

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

Mobile First Platform v 7.1 cannot register the devices

We have done the installation and configuration of MFP 7.1V with WAS 8.5.5.0 V successfully.Here we are able to access the operation and analytics console and able to add the application (.wlapp files) and adapter files and able to access those application in tab by instantiating an apk files in the tab.
But here the issue we are facing is we are not able to get the devices list in the operation console and analytics and devices tracking in the analytics console.
So essentially I guess the issue is that the applications fail to connect to the server at all. Please edit your question with the full client-side log with the errors.
Until then my suggest is to verify in the generate .plist/.properties file that you are indeed attempting to connect to the correct server. Verify the host, port and context-root values in the files.

Android server not available at http://localhost:8085/wd/hub

I am in the means of setting up of android web driver and followed the same steps as mentioned in the url : http://code.google.com/p/selenium/wiki/AndroidDriver
1) Downloaded the android SDK for windows and unpacked and placed in the path of selenium repository
2) Set up the emulator and created the new AVD ( android virtual device )
3)Installed the webdriver apk 4)port forwarding in order to forward traffic from the host machine to the emulator.
In a terminal type:
$./adb -s forward tcp:8085 tcp:8085(since 8080 is occupied I'm using 8085)
5) This will make the android server available at //localhost:8085/wd/hub from my system.
But when i went to localhost:8085/wd/hub it displayed could not connect to www.localhost.com:8085. May I know why? Kindly help me to fix this.
When you say, "But when I went to" do you mean you visit the url in your browser? It sounds like your browser does not know what to do with the url and tries to be smart for you and assume you mean www.localhost.com:8085. If so, just add a protocol to your request. In stead of localhost:8085/wd/hub use http://localhost:8085/wd/hub.