Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Connection Problems over Cellular

Tags:

android

We have discovered a strange bug in on of our Android apps in that the app cannot connect to the internet over cellular on certain Android Models/Mobile Networks (connecting via WiFi works perfectly). The URL which the app is trying is to reach is however accessible using the device's normal browser, which rules out the URL being blocked upstream. Any ideas what could be causing this would be appreciated please.

like image 230
RunLoop Avatar asked Nov 12 '12 08:11

RunLoop


2 Answers

which rules out the URL being blocked upstream

Not necessarily. As one of the commenters pointed out, you do not indicate how you are using this URL in your app. If this is an HTTP request, and it works in a browser but not your app, try changing the User-Agent HTTP header of your request to match the one from the browser.

like image 65
CommonsWare Avatar answered Oct 29 '22 21:10

CommonsWare


You have provided no error log, but from experience I have run into a few inconsistencies when connecting to a server.

Using HttpsUrlConnection a SNI header is set on HoneyComb and above but not on previous versions, which can alter how the server responds. To add to this there are some general SSL handling inconsistencies between API levels, such as handling of wildcard domains in a certificate is buggy in some api levels.

Second some phones/api levels add a header to HttpUrlConnection requests that specifies time the request was sent like so:

X-Android-Sent-Millis=1353085024868

Some servers seem to use these headers to detect mobile traffic and alter the response.

like image 26
Emil Davtyan Avatar answered Oct 29 '22 20:10

Emil Davtyan