0

I found an issue in Samsung S5 with using HTTPURLCONNECTION may be I'm doing wrong but if any one have an idea kindly guide me.

Here is my code :

URL urls = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urls.openConnection();

connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("x-os-application-token", Constants.APPLICATION_TOKEN);

connection.setConnectTimeout(900000);
connection.setReadTimeout(150000);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);


DataOutputStream wr = new DataOutputStream(
        connection.getOutputStream());
wr.writeBytes(json);
wr.flush();
wr.close();


int responseCode = connection.getResponseCode();

Now using this code if I manually Internet disconnect (WI_FI OFF) then other device (e.g. Nexus 5 and Samsung Galaxy Note 3) give me response immediate but In Samsung S5 it respond me after connection.setReadTimeout(150000) ??? 2.5 minutes

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Arpan24x7
  • 648
  • 5
  • 24
  • your read time out is too much can't you set it to 5 seconds? – Raghunandan Nov 09 '16 at 05:42
  • **give me response immediate**. what do you mean by that? – Raghunandan Nov 09 '16 at 05:45
  • @Raghunandan "your read time out is too much can't you set it to 5 seconds?" My read time 150000 milliseconds which is 2.5 minuts not 5 sec. – Arpan24x7 Nov 09 '16 at 06:04
  • @Raghunandan "give me response immediate. what do you mean by that? " that mean i set an alert which give me status of my internet connectivity status real time. – Arpan24x7 Nov 09 '16 at 06:06
  • i know. i said that ideally its should be 5 seconds not 15 seconds. If there is no read you get readtimeoutexception which you need to handle. there is nothing wrong with the code that i can see – Raghunandan Nov 09 '16 at 06:06
  • yes there is nothing wrong in code but my concern is related response time why the s5 respond me after 2.5 minute – Arpan24x7 Nov 09 '16 at 06:08
  • All you can do is reduce the time out to say 5 seconds. I don't have a samsung s5 phone. But i don't think you can do much – Raghunandan Nov 09 '16 at 07:51

0 Answers0