Home HttpUrlConnection File Not Found Exception android 6.0
Reply: 0

HttpUrlConnection File Not Found Exception android 6.0

user2676
1#
user2676 Published in April 23, 2018, 9:36 am

I'm having an issue with my HttpUrlConnection. This is my source code,

String body = ("My Soap request Body");
   String URLString = "myURl";
                String SOAP_ACTION = "mySoapActon";


                URL url = new URL(URLString.trim());
                HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

                urlConnection.setRequestMethod("POST");
                urlConnection.setRequestProperty("Accept", "xml/text");
                urlConnection.setRequestProperty("SOAPAction", SOAP_ACTION);
                urlConnection.setDoOutput(true);
                urlConnection.setInstanceFollowRedirects(true);
                urlConnection.setConnectTimeout(2000);


                writer = new OutputStreamWriter(urlConnection.getOutputStream());
                writer.write(body);
                writer.flush();

Whenever i make the request to the server using wifi on android 6.0, i get a proper response, but whenever i switch to mobile data and make the same request, i get a 404 file not found response.

These are the logs am getting from my server :

Using wifi connectin :

[ 17 Apr 2018 09:33:26:413 ] Raw Message Received: [POST /SOAServices/CreateSession [Accept: text/xml, SOAPAction: http://www.mysoaptest.com/CreateSession, Content-Type: application/x-www-form-urlencoded, User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; SM-N910H Build/MMB29K), Host: 197.938.392.34:8028, Connection: Keep-Alive, Accept-Encoding: gzip, Content-Length: 455]]

//The above request returns the correct response.

But when i use mobile data these are the logs i get :

[ 17 Apr 2018 09:32:26:789 ] Raw Message Received: [POST http://197.938.392.34:8028/SOAServices/CreateSession [Accept: text/xml, SOAPAction: http://www.mysoaptest.com/CreateSession, Content-Type: application/x-www-form-urlencoded, User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; SM-N910H Build/MMB29K), Host: 197.938.392.34:8028, Connection: Keep-Alive, Accept-Encoding: gzip, Content-Length: 455]]
[ 17 Apr 2018 09:32:26:933 ] Message Responded: [HTTP/1.1 404 Resource Not Found []]

//The above returns 404 file not found

You will note that in the first request, the request doesn't start with the actual url i.p address but when i make the request using mobile data, the full url is included and thus returns a 404 exception.This issue doesn't occur on android 5 nor android 7, only on android 6. What could be the issue?

Kindly note the above are not the real url's, due to client confidentiality.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.50134 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO