Proxy connection issues

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Proxy connection issues

Postby cp77 » Fri Mar 19, 2010 2:54 pm

Hi,

I'm new to Android and Java, but I am a 'proper' developer.

I'm trying to get the emulator to work behind the company proxy, and thought I had it cracked but I haven't. I've set up the APN using the proxy name, port, username and password and now the Browser application is happy it will pull pages back and display them. But following the HelloGoogleMaps and HelloWebView tutorials off the main Android site and they don't work. I tried them on the other side of the proxy and they work fine for both (so my Google key is OK).

So what I know is...
-http-proxy apparently doesn't work
-verbose-proxy should be –debug-proxy but it doesn’t tell me much anyway
I have...
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.INTERNET" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

...in my manifest file.
The SQL INSERT may work but I find it a little offensive that I have to do it so am still looking for a cleaner official way of resolving this.

I'm concluding that this must be a proxy issue as the code works fine on the other side of the proxy, but I'm struggling to see how to set the proxy up correctly for applications. I thought setting the APN would be enough but it appears not to be.

Do I need to tell the app to use the APN or something? How? As I say I’m new to Java and Android so I don't know if this is a Java thing or an Android thing.

Can anyone help?
Thanks,
- Chris.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Top

Postby billd » Tue Mar 23, 2010 9:17 pm

Hi Chris,

I can't help, but if it makes you feel any better, I'm having the same problem.

I'm using the 1.6 version of Android with Eclipse and Android ADT. When I open the emulator and use the browser app provided, I can access the internet. I had to change the proxy name, port, username, and password to use the company network. However, when I create my own app, using the HelloWebView tutorial on the Android website, it does not load a web page. I've been Googling all day and trying various solutions proposed, but none work. It does seem like the browser knows to use the defined APN, but my app does not.

Regards,
Bill
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby billd » Wed Mar 24, 2010 12:39 am

billd wrote:Hi Chris,

I can't help, but if it makes you feel any better, I'm having the same problem.

I'm using the 1.6 version of Android with Eclipse and Android ADT. When I open the emulator and use the browser app provided, I can access the internet. I had to change the proxy name, port, username, and password to use the company network. However, when I create my own app, using the HelloWebView tutorial on the Android website, it does not load a web page. I've been Googling all day and trying various solutions proposed, but none work. It does seem like the browser knows to use the defined APN, but my app does not.

Regards,
Bill


I just verified that I can access the internet by using the HelloWebView app when trying it from my home PC. Must be something related to the company network and the application.
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby cp77 » Wed Mar 24, 2010 10:40 am

billd wrote:I can't help, but if it makes you feel any better, I'm having the same problem.


Yes! Yes it does!!!! :D

One of the guy's here said in the past they have struggled with our authenticating proxy, so I changed to one that isn't authenticating but I still have the same problem.

I did the same, I took it home and all was fine. I'm going to speak to the IT bod's today and see if they can let me tunnel through the proxy. If I find a solution I'll let you know.

- Chris.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby billd » Wed Mar 24, 2010 6:24 pm

Hi Chris,

I got it! :D

I've been trying to find a way for my HelloWebView application to use the same APN information that the native browser application seems to be using. I first tried looking through the code samples provided with the SDK, hoping that a WebView example was included. There was, but it did not load a URL like this example. I also did a few searches of the whole SDK, looking for anything related to APNs, but did not find anything substantial.

I then guessed that perhaps Eclipse was somehow passing this info to the emulator, considering that the emulator is launched from Eclipse. I found the Window->Preferences->General->Network Connections menu and have been playing around with that for much of today.

I found that when I set my Active Provider to "Manual", enter my company Host, Port, Username, and Password information in for HTTP, HTTPS, and SOCKS proxy entries, and created a Proxy Bypass for my company host, it worked. It took a loooooonnnnggg time to display the Google.com web page, but it worked.

Right now I'm checking a few other things out in my java code to make sure if they are needed our not. I've added some things based on other attempts that may not be relevant.

Regards,
Bill
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby cp77 » Wed Mar 24, 2010 6:39 pm

Cool, well done Bill!

I'll try this in the morning...on first go it didn't work :?

- Chris.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Top

Postby billd » Wed Mar 24, 2010 8:40 pm

cp77 wrote:...on first go it didn't work :?


I'm having lots of trouble getting any consistent results. Sometimes the application fails to install and launch at all, sometimes it struggles for 10 minutes before declaring "Web Page Not Available", sometimes it struggles for 4 minutes before declaring "Authentication Failed", and sometimes it comes up fine. It's making it hard for me to determine which changed are necessary and which are not. I'll keep plugging away.
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby cp77 » Thu Mar 25, 2010 10:40 am

I've arrived at work refreshed and ready again. I'll try from this end too!
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby cp77 » Thu Mar 25, 2010 12:25 pm

I've tried setting the proxy through Eclipse and it isn't doing it in any possible combination of options.

I did another search and found this...

http://code.google.com/p/android/issues/detail?id=1273

...not good reading. If you get past all the complaining it would appear there are few technical solutions in here. The last post was yesterday.

You probably checked this already but looking at a packet sniffer on the network the browser is happily using the proxy set via APN but the WebView is not. It performs DNS then starts the TCP sequence to make the HTTP connection, obviously it fails.

Given the thread above and all the other stuff we've seen I don't think this is simply fixable. I've asked for an ADSL port at my desk.

- Chris.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby billd » Thu Mar 25, 2010 3:21 pm

cp77 wrote:Given the thread above and all the other stuff we've seen I don't think this is simply fixable. I've asked for an ADSL port at my desk.


Before you give up, try this. . . . .

I've been able to narrow this down a bit further. It turns out that one of my changes to the Java code may be the key. I added the following line at some point during my efforts:

mWebView = (WebView) findViewById(R.id.webview);
WebView.enablePlatformNotifications();
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");

This goes in onCreate().

I haven't been able to find much info on this method, other than the one sentence description in the Android help files: "Enables platform notifications of data state and proxy changes". Perhaps someone more knowledgeable about this can comment.

I was also able to remove one of the items from Eclipse that I mentioned yesterday. . . . the Proxy Bypass. . . . .and it still works.

Remember to give it a while when you invoke the emulator. It takes mine 10 minutes to give a "Not Available" message and sometimes up to 4 minutes to connect to the internet when successful.
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby cp77 » Thu Mar 25, 2010 4:13 pm

Yes that is a particularly poorly documented API!

So doing...

WebView.enablePlatformNotifications();

...worked, but only on the second run of the WebView application.

So I have a theory that as I'm running my app on start-up automatically from Eclipse the OS is still sorting itself out when the first WebView HTTP request goes off. When the second one goes off it's using the proxy and gets the page back OK. I have confirmed this with Wireshark. So I guess our apps need to wait for a notification from the NetworkConnectivityListener class before we start doing networky type stuff.

I'm reading about the NetworkConnectivityListener now.

As an asside I tracked a guy down here who admitted to having proxy issues a couple of years ago due to the MS proxy not terminating chunked requests correctly. But I think this has been fixed since in the SDK.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby cp77 » Thu Mar 25, 2010 4:24 pm

Hmm, but if we're still sending the first request out before the proxy is set by the OS how do we know when it'll be OK to actually send the request out...we need a proxy set event.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby cp77 » Thu Mar 25, 2010 4:43 pm

Don't waste time looking at that class, it looks deprecated. It has a bigger brother that I'm looking at now.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Postby billd » Tue Mar 30, 2010 3:11 pm

Did you ever get any farther in solving this problem? I haven't had a chance to look at it in a few days. I may just start on the Maps tutorial since we seem to be stuck. Hopefully that one won't be as problematic.
billd
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 23, 2010 9:10 pm

Postby cp77 » Tue Mar 30, 2010 3:30 pm

I caved in and got them to open the proxy server up for the sites I need :-(

I'm pretty disappointed with this as an approach.
cp77
Junior Developer
Junior Developer
 
Posts: 14
Joined: Fri Mar 19, 2010 11:57 am

Top
Next

Return to Networking & Database Problems

Who is online

Users browsing this forum: Google [Bot] and 4 guests