Issue
I have an app that relies on making POST/GET requests. My app is being tested by a variety of devices on the same wifi network.
On some devices I get the standard timeout exception for HttpURLConnection.
Below is where the timeout occurs:
HttpURLConnection conn = (HttpURLConnection) ((new URL(
getString(R.string.base_url) + "/getnumbers").openConnection()));
conn.setDoOutput(true);
conn.setConnectTimeout(MainActivity.CONNECT_TIMEOUT_MS);
conn.setReadTimeout(MainActivity.READ_TIMEOUT_MS);
conn.setRequestProperty("Cookie", prefs.getString("sessionid", ""));
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod("POST");
conn.connect();
JSONObject progress = new JSONObject();
try {
progress.put("username", prefs.getString("username", ""));
} catch (JSONException e) {
e.printStackTrace();
}
// posting it
Writer wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(progress.toString());
wr.flush();
wr.close();
is = conn.getResponseCode() >= 400 ? conn.getErrorStream() :
conn.getInputStream();
This app works fine with the following devices:
Samsung Galaxy S4 Verizon 5.0.1
Samsung Galaxy S5 Verizon 6.0.1
Samsung Galaxy S7 AT&T 6.0.1
Samsung Galaxy S7 Verizon 6.0.1
Samsung Galaxy S7 Edge Verizon 6.0.1
BLU R1 HD N/A 6.0.1
Galaxy Tab S2
LG G4 Verizon 6.0.1
- LG G2 Verizon 5.1.1
- Google Pixel At&t 7.1.1
- Sony Xperia Z Ultra Verizon 5.1.1
Here is the list of devices that cause the timeout issue:
LG Tribute HD No Plan 6.0.1
LG V10 Verizon 6.0.1
LG Zone 3 5.1.1
Samsung Note 4 ATT&T 6.0.1
I tried fixing the timeout issue by extending the timeout duration and by doing System.setProperty("http.keepAlive", "false"). None of these measures helped.
Considering that the timeout occurs on the same Wifi network, I am fairly certain that the issue is caused by the vendor specific bloatware or some other device/vendor/operator specific problem.
Can anyone share their ideas thoughts as to what might be causing this?
java.net.SocketTimeoutException
W/System.err: at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488) W/System.err: at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37) W/System.err: at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
Solution
Ok, so releasing the app through Play Store seemed to solve the problem with (at least) one of the devices (the Note 4 which had updated to 6.0.2 recently).
So some of the devices seem to timeout when APKs are installed directly but work when installed via Play Store.
Answered By - 372
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.