Internet access on Android device behind proxy with authentication - android

I am unable to connect to the Internet through android emulator 2.2 which is behind a proxy that requires proxy authentication.
Searched a lot over the Internet to find a proper solution but none of them are working for me.
I am running the emulator on a Ubuntu machine.
Situation:
I have an application which is designed to run on both ubuntu(linux) and android.
This application has a feature to connect to internet by providing proxy details and it connects properly when run on ubuntu after providing correct details. however this fails to connect through the emulator.
Even the web browser on the emulator doesn't connect to internet. Doing some changes in APN settings, it atleast gave me a webpage saying that the ISA server needs authentication, but never got any popup requesting to enter those details.
By applying -debug-proxy flag to emulator, the logs showed that it is trying to connect to the requested proxy server, but the server is challenging with authentication and none of the applications seem to get a chance to fill in this details and hence failing. This is what is happening with my application.
Does anyone have any clue why this could be happening and how i can resolve this issue?
Thanks in advance.
P.S. This is happening on actual android devices as well, so it may not be the problem of just the emulator.

Puneet ... Do as viv said and along with this give proxy address in its IP format instead of giving its DNS name. I have read some where that it is having problem in resolving DNS name.

Tell me if I'm wrong but I think Puneet is talking about wifi connection. So the solution is not to configure an APN as it's for mobile networks. I got the same problem and I'm still searching for a solution...

There is a simple method by which you can get internet access on the device but only for browsing. Except the browser no other apps will have access to internet. You can find detailed information on http://androidproxy.blogspot.in/2011/01/setting-up-proxy.html.
In order to get the IP address just ping the proxy server in your organisation. By default the port is 8080.

You can use Proxy Manager application to connect to internet from behind a authenticated proxy.

Try this:
Go to setings -> wireless and networks -> Mobile networks -> Access point name.
If you see any entry here, edit it's settings

I know this is an old post but just for people asking the same question, I did connect from my phone in proxy network that required authentication by using the Autoproxy app that is now in the android market: https://market.android.com/details?id=com.mgranja.autoproxy_lite&feature=search_result&rdid=com.mgranja.autoproxy_lite&rdot=1&pli=1

if you use webview, you can override onReceivedHttpAuthRequest method of webviewclient when set it.
mWebView.setWebViewClient(new WebViewClient() {
#Override
public void onReceivedHttpAuthRequest(WebView view,HttpAuthHandler handler,String host, String realm) {
handler.proceed("username", "password");
}
});

Related

Couldn't connect internet in xamarin android emulator -AVD_for_Nexus_One_by_Google

I have created simple listview apps using xamarin form and data are coming from webservices.
My current problem is , i couldnt connect internet my android emulator. Please anyone can guide how to do?
My Error image
Notes: My PC connected internet via LAN.
Connecting to the Internet from an Android emulator can be tricky.
One common issue is falling foul of a network proxy. If you have one on your network you need to configure it on the emulator.
Here is an article detailing Android emulator network settings.
You should check the connection settings of your emulator when you create one try creating one more emulator and revert us so we can help you create one.
The way i suggest you do it is use the emulators that visual studio provides check visual emulators in your respected search menu to find it .
One of the problems could be you do not have internet permissions which you can update in your manifest using this line:
<uses-permission android:name="android.permission.INTERNET" />
If this doesn't work follow the steps below :
1.Go to settings->Wireless & networks->mobile networks->Access Point Names.
2.Press menu button. an option menu will appear.
3.from the option menu select New APN.
4.Click on Name. provide name to apn say My APN.
5.Click on APN. Enter www.
6.Click on Proxy. enter your proxy server IP. you can get it from internet explorers internet options menu.
7.click on Port. enter port number in my case it was 8080. you can get it from internet explorers internet options menu.
8.Click on User-name. provide user-name in format domain\user-name. generally it is your systems login.
9.Click on password. provide your systems password.
10.press menu button again. an option menu will appear.
11.press save. try n run your browser. hope its work for you it worked for me. good luck.

Error: ConnectFailure (No route to host)

Context: I have a Xamarin.Android app that it connects to an WebAPI for different information.
Issue: When trying to access the server I get the following error:
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (No route to host)
Issue context: we have 2 servers in the same network, configured the same (at least we hope so, is at client site) and if we use the same app (same build) we can connect to server A, but get the mentioned error when connecting to B. About the B server: I can access from device browser the http://address/help or /token page, I can also do the desired request from 'REST Api Client' from Google Play and get a successful response. The only problem it seems when connecting from our app to the server B. This issue is also not present on our environments (as I mentioned, the A and B are at client site).
Question: What would be the problem and where should we look further?
Thank you!
I found this answer on Xamarin forms, this didn't solve my problem, but maybe it could help in yours. https://forums.xamarin.com/discussion/70731/connection-error-no-route-to-host-only-happens-on-android
I had this problem because I didn't dispose my HttpClient object. It didn't happen with the first or second request, however from request 10 it would start giving me problems. Especially when they were happening asynchronously.
I don't know if this will solve your problem, as both these seem to be a special case instance. Maybe yours is a special case as well.
Check the mobile device can able to access the API server first. Is completely related network issue. Might be your mobile app and web server used different LAN connections or WIFI networks.
I had same issue, fixed it by enabling fast deployment:
In solution explorer, right click on 'yourproject.Android' -> 'Properties' -> 'Android Options' -> check 'Use Fast Deployment'
In my case, the problem occured only when running the application through the Visual Studio 'Run' button (I used a physical device to debug on).

Unable to access server using real android device

I'm having trouble accessing my server (WAMP) using my real android device. I have an app that downloads the data and parsing it to my listview. In the emulator everything is working fine using "10.0.2.2" I tried 10.0.2.2:80, 10.0.2.2(without port #), (my laptop's ip) 192.168.254.103:80 and 192.168.254.103 (without port #) in my url. My WAMP is online and I even tried turning off firewall. Is there something missing?
UPDATE
I tried browsing via my phone's browser the ip address of my laptop and it says "FORBIDDEN". i tried configuring the httpd.conf of apache based on what I've researched but still can't access the server. please help.
Turn off Firewall -
Give permission to "WAMP folder" by using Folder
sharing options - Basically access to "All" for read, write

SUP android native app

Is it possible to have user put in connection properties like ip address in the app to connect to Sybase. I need to find out for a test to connect to our DR Site which has a different IP address. (So user uses production system and something happens and need to switch to the DR Site to continue working.)
Thanks
Louis
I don't know much about SUP, but it seems the IP address of the server is in the generated code (Activity classes), you cam edit this code to get the IP from somewhere (e.g. the application settings).
If you don't have access to the source code of the application and this is just for a test you can configure your android device to use a proxy (How to change proxy settings in Android (especially in Chrome)) and then make a simple proxy that redirects connections to another host (such as those described in seriously simple python HTTP proxy?).

Can't run IBM worklight app in real device android

I build a worklight application. create android app and test this application with local machine , its working fine with emulator.but when i try to test this application with android tablet it through error "The Application failed connecting to the service".
I try to find application-descriptor.xml and fix localhost to 192.168.1.1:8080
my ip local machine,but it not working.In my tablet I can't to go to 192.168.1.1:8080/console/index.html
Can anybody help me regarding this issue. how can i fix this one in my worklight android application and run it on my android tablet
Some things to check:
- Are your tablet and your worklight development machine on the same wireless network? (they need to be!)
- Does your computer have a firewall on it which may need configuring to let the traffic through. As a test you could briefly disable the firewall and see if you then have access (subject to disclaimer of the risk involved in disabling the firewall). A test without disabling the firewall would be to try accessing 192.168.1.1:8080 from another desktop/laptop machine on that same subnet.
Check ip in local machine ipconfig ( field Adaptador de Ethernet )
Set this IP in field host name configuration server.
Rebuild
The other test is to check the direction in other machine, in the same network.
In a command window, run ipconfig and copy the IPv4 address. This is the IP address you need to place as the value for worklightServerRootURL in the file application-descriptor.xml.
The IP address you are usingnow does not look to me like the correct (public) IP address that you need to use. Try my above suggestion.
How about adding "192.168.181.1:8080" in application-descriptor.xml?
I would suggest the following debugging steps:
a) Go to your device browser and browse to http:
//xx.xx.xx.xx:8080/console
-> If this doesn't work, you have an obvious ip address issue. Then you have to figure out why, maybe you have a Symantec thingy that blocks any incoming traffic to your desktop - which they do. You should do an explicit allow.
b) If a) works, then you need to check in your code to make sure your app does try to connect to the server at startup. Or else the app will only try to connect when it calls adapter.
Now, go to your code. open the initOptions.js file. I typically, would set connectOnStartup to true, but also enable the onConnectionFailure so that it runs offline when there is no connection.
var wlInitOptions = {
// # Should application automatically attempt to connect to Worklight Server on application start up
// # The default value is true, we are overriding it to false here.
connectOnStartup : true,
// # The callback function to invoke in case application fails to connect to Worklight Server
onConnectionFailure: function (){wlCommonInit();},
// # Worklight server connection timeout
timeout: 2000,
};
3) Make sure you have the right URL in the application-descriptor.xml
<worklightServerRootURL>http://xx.xx.xx.xx:8080
</worklightServerRootURL>
If you are using the consumer edition (the real purchased WL), your URL would be.
<worklightServerRootURL>http://xx.xx.xx.xx:9080/worklight
</worklightServerRootURL>
(Note no space in between those URL - it's just this website putting a space there when there is a line break)
Redeploy your code to the WL server and create a new APK file. Update your device with the new APK file.
4) Do a test with the console again, you should see the console. Click on the Preview app link, it should work.
5) Now that you have updated your code on the server and the APK file. Open it up again on the device.
Do you still see the error message?
If things still not work.
6) Go to the app setting, since you have enable offline mode, it would allow you to access the App settings (it's the 4th button in Android) Go to Worklight Settings. Select Server Address -> Add the worklight URL to the Server URL. When you go back to the app, this will automatically reload the content from your WL server.

Categories

Resources