Apps are unable to access internet in Android Device with Proxy - android

I have a requirement of doing Performance Testing of Android apps as given here [http://blazemeter.com/blog/load-testing-mobile-apps-made-easy] . But when I change the proxy hostname of my Android device to that of my laptop's IP, the apps are unable to access the internet. Though, the browser works fine and are able to send the requests. It is getting recorded in JMeter as well. But, the apps are unable to access the internet. Is it because they don't have the permission to access the internet because of the changed proxy?

A main reason that the apps won't work but the browser will, is the use of https.
If you are using the secure protocol in your applications, they don't know how to retrieve the certificate through the proxy, but the browser does. You will have to get the certificate yourself, and put it on the phone.
As is written in the article you mentioned:
Note that Android supports only HTTP proxy. If your application uses
an HTTPS connection, then you may use an additional application that
performs with HTTPS proxing.

Related

Unable to make local network calls using IP address on deployed react native app

My react-native android app uses the IP address of a smart device on the local network to communicate with it. This works perfectly in testing but now that I've launched the app for internal testing this call fails.
Ex call is: http://192.168.88.39:8080/version
This call works perfectly in development, but not on the deployed app. I was previously using a hostname to resolve the IP address of the device on the local network but realized this didn't work with Android, so I switched to using the IoT device's IP address to communicate with it.
But to my surprise that isn't working. I've also tried to setup a Charles proxy to intercept the requests but have been unable to do so successfully so I'm not sure what the exact response is from the http request.
But I know it doesn't resolve.
So firstly is this even possible to do? Want to make sure this is not prohibited?
You cannot access http urls in a production build. Check this question for possible solutions Android 8: Cleartext HTTP traffic not permitted

In android's Google Chrome, how to set unsafely-treat-insecure-origin-as-secure

I'm using getUserMedia() in my web app which works fine when I test my app on localhost. But if I treat my laptop as server and launch app in Google Chrome browser of my android phone, it gives me the error:
getUserMedia() no longer works on insecure origins. To use this
feature, you should consider switching your application to a secure
origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
When I checked [https://goo.gl/rStTGz][1] I got to know that getUserMedia() is deprecated on insecure origins. It is written that for development mode,
You can run chrome with the
--unsafely-treat-insecure-origin-as-secure="example.com" flag (replacing "example.com" with the origin you actually want to test)
How and where can I set this flag? Is there any other alternative?
This can be done from chrome://flags/ or about://flags.
Go to about://flags, search for unsafely-treat-insecure-origin-as-secure flag, and enable it. You will have to provide the origin which you want to be treated as secure.
Multiple origins can be entered as comma-separated values.
Relaunch your browser after making this change.
Note that the protocol part is also important, and specifying the IP address, or the domain name isn't enough. eg. http:// in http://192.168.43.45. If you are not using port 80, then you may have to specify that too.
The following is a screenshot from my mobile phone.
Mobile: Samsung Galaxy S10e
Android version: 10 (Android 10)
Google Chrome version: 79.0.3945.136
For local testing of a website I am building, geolocation was needed.
Geolocation is allowed in secure locations. I do have a production server with HTTPS certificate, but the development and the debugging process would become too slow if I have to upload content to it every time.
More info
https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features
Move localhost to the device
One method is to run an HTTP server on your Android device. The consensus in answers to this question is that NanoHTTPD is worth trying. If you want a ready-made application, a web search for http server for android turned up Simple HTTP Server on Google Play Store. After copying the client side of your web application to the device and starting the server, you should be able to open http://localhost:12345 in Chrome for Android.
Or make your test server secure
You can test secure-context-only features without using --unsafely-treat-insecure-origin-as-secure by turning your existing test server into a potentially trustworthy origin. Follow these steps:
If you do not already own a domain at a registrar that bundles DNS hosting compatible with the dehydrated ACME client, register one. This incurs a fee, which recurs as long as you keep the domain active.
Point a subdomain at your test web server's internal IP address. It need not be reachable from the Internet.
Configure your test web server to respond to HTTPS on port 443 of this subdomain, using NameVirtualHost or the like.
Use the dehydrated ACME client with the appropriate dns-01 hook for your DNS host to obtain a certificate from Let's Encrypt for your test web server.
Install this certificate into your test web server.
I faced with this problem too, but in Chromium, Ubuntu. I solved the problem with running this command in console:
chromium-browser --unsafely-treat-insecure-origin-as-secure="http://localhost.dev:3000" --user-data-dir=~/.config/chromium/Profile 1
where localhost.dev:3000 is your website.
For other systems information there:
where is data directory
how to launch chrome and set keys
Short information about --unsafely-treat-insecure-origin-as-secure flag:
Treat given (insecure) origins as secure origins. Multiple origins can
be supplied. Has no effect unless --user-data-dir is also supplied.
Example:
--unsafely-treat-insecure-origin-as-secure=http://a.test,http://b.test --user-data-dir=/test/only/profile/dir
I didn't check, but for android you maybe can also set flags on chrome://flags page.

Mobile Application Testing With Jmeter

In our organization we are using Proxy to connect mobile devices with Internet.
Can anyone please help to configure mobile device to work with Jmeter.
As my understanding we have to configure Jmeter Proxy into mobile device to work with,But if i ma configuring that into mobile my internet will stop working.
Ideally you will be using a test mobile device, rather than an active mobile on a real live account.
However, the Jmeter Proxy should be configured to point at your current proxy. It is inserted into a chain, rather than replacing the chain. Therefore your mobile internet should continue to work as long as the jmeter proxy is running.
Here is the official guide to setting up Jmeter Proxy:
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
If using a test device/account is not an option, then you will need to switch the proxy on the device whenever you want to stop testing and use the device normally. You can probably find an app to make the switch easier.
Your mobile devices can be configured to use JMeter proxy server. In that way you can record the HTTP requests you send to the server.
I had a similar issue. This post clarifies it.
JMeter recording iOS native application that uses HTTPS leads to SSL handshake issue
I've done it successfully. For that you"ve to use ApacheJMeterTemporaryRootCA file on your device.

Using Fiddler2 HTTP request inspector with an Android device

For a project working I need to inspect the HTTP requests sent and received from my Android device. I'm using this tool Fiddler2 to monitor the traffic. In order to get it working I had to pass the traffic through a proxy. Now my phone is a Huawei U8180. Its runs Android 2.2 so it doesn't have a direct way to proxy settings. I used this app called Proxy Settings to gain access to set the proxy settings.
It almost works. I can see the traffic say, if I navigate to a website using the proxy web browser in that app (The app comes with a proxy browser). But not using my phone's normal browser. Neither I can see any HTTP requests sent by any of my apps installed in my device.
If anyone has any experience using Fiddler2 with Android, I'd really appreciate your input. I'm open to try any other alternatives to accomplish this if you got any.
Thanks.
Typically, Android users will use a tool like iptables to capture traffic from apps that don't support a proxy setting. This has some implications for HTTPS decryption; see the Fiddler Discussion Group (Help > Fiddler Community) for discussion of how to adjust Fiddler's HTTPS settings to accommodate iptables-redirected HTTPS connections.

unable to connect to https site on via both code and native browser

I have an android application that makes a https connection to a backend. I have successfully added the required certificate (obtained from the backend and converted to bks format) and the app can connect when running on 2.2, 2.3 and 4.0.2 emulators. However on my huawei u8860 (honor) with ics 4.0.3, the app doesn't connect and worst of all it doesn't give any exceptions in the log. On the phone also, I can't point the native browser to the backend but i can using google-chrome for android. I've searched high and low on but found no explanation for this behaviour. any ideas?! Thanks in advance
I suspect the problem is caused by your mobile carrier.
Some of them perform nasty filtering of HTTP requests, based on the User-Agent header (they'll block requests that do not seem to come from a mobile device).
You should try your app on your phone, using a Wifi connection to confirm/infirm this hypothesis.
If it works on Wifi, you should try to change the User-Agent of your HTTP requests, by either setting it to:
A hard-coded Android Chrome or iPhone Safari User-Agent (that you carrier probably does not block)
The User-Agent of your own device's browser that you should get with getUserAgentString()

Categories

Resources