Search code examples
androidwifiandroid-4.0-ice-cream-sandwich3ghttp-status-code-403

Android ICS connection via 3G getting 403 response but OK via Wifi


I'm getting a strange issue on Android ICS, I have the following code to stablish a connection to read an xml file:

// previous code......

URL url = new URL("https://urltomyxmlfile.com/xmlfile");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
XML_handler myXML_handler = new XML_handler();
xr.setContentHandler(myXML_handler);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(25000);
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
xr.parse(new InputSource(input));

//more code....

This code works properly in all android versions both wifi and 3G but in Android ICS only works with wifi, on a 3G connection I'm getting a 403 response.

I can't figure the origin of this issue, Am I not properly configuring the connection? Is there any new restriction in Android ICS? problems with https?

Extra info: this code is not running in the UI-thread

Thanks for your help!

New Extra info: I have discovered that only Samsung Galaxy SII users are experiencing the issue.


Solution

  • Finally I got the answer!!!, it was not code related.

    Spanish carrier ORANGE is selling terminals and sending OTA updates with a wrong APN configuration. Please find pasted below the correct APN configuration to avoid this issue for the main Spanish Carriers (Vodafone, Movistar, Orange, Yoigo and Simyo)

    VODAFONE ES-INTERNET

    Nombre: Vodafone ES APN: airtelwap.es Proxy: No establecido Puerto: No establecido Nombre de Usuario: wap@wap Contraseña: wap125 Servidor: No establecido MMSC: null Proxy MMS: No establecido Puerto MMS: No establecido MCC: 214 MNC: 01 Tipo de APN: default

    MOVISTAR -INTERNET

    Nombre: Movistar APN: telefonica.es Proxy: 10.138.255.133 Puerto: 8080 Nombre de Usuario: telefonica Contraseña: telefonica Servidor: No establecido MMSC: No establecido Proxy MMS: No establecido Puerto MMS: No establecido Código País del Móvil (MCC): 214 Código de Red Móvil (MNC): 07 Autentificación: No establecido Tipo de APN: internet

    ORANGE -INTERNET

    Nombre: Orange Internet APN: internet Proxy: No establecido Puerto: No establecido Nombre de Usuario: cliente Contraseña: amena Servidor: 62.36.225.150 MMSC: No establecido Proxy MMS: No establecido Puerto MMS: No establecido MCC: 214 MNC: 03 Tipo de APN: default

    YOIGO-INTERNET

    Nombre: Yoigo APN: internet Proxy: 10.08.00.36 Puerto: 8080 MMSC: Proxy MMS: Puerto MMS: MCC: 214 MNC: 04 Tipo de autentificacion: PAP Tipo de APN: Internet

    SIMYO -INTERNET

    Nombre: SimyoInternet APN:gprs-service.com Proxy: No establecido Puerto: No establecido Nombre de Usuario: No establecido Contraseña: No establecido Servidor: No establecido MMSC: No establecido Proxy MMS: No establecido Puerto MMS: No establecido MCC: 214 MNC: 19 Tipo de APN: default