Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping silent retries in HttpURLConnection

I'm using HttpURLConnection on Android KitKat to POST some data to a server. The server takes a long time to respond, and the connection is silently retrying 1 to 3 times before timing out. I don't want it to retry, since the server acts on all of the requests, resulting in Bad Things(TM).

I've tried System.setProperty("http.keepAlive", "false") before opening the connection, but that doesn't help.

like image 885
Erik Browne Avatar asked Jun 25 '14 20:06

Erik Browne


1 Answers

For POST calls set

httpURLConnection.setChunkedStreamingMode(0);

and this should fix the silent retries. The bug report and workaround can be found here.

like image 188
Espen Riskedal Avatar answered Nov 07 '22 16:11

Espen Riskedal