停止无声重的HttpURLConnection的 [英] Stopping silent retries in HttpURLConnection

查看:916
本文介绍了停止无声重的HttpURLConnection的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的HttpURLConnection 上的 Android的奇巧的一些POST数据到服务器。服务器需要很长的时间来响应,且连接默默地重试1〜3次超时之前。我不希望它重试,由于服务器作用于所有的请求,导致坏事(TM)。

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).

我已经试过 System.setProperty(http.keepAlive,假)之前打开连接,但这并不能帮助。

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

推荐答案

有关设置POST调用

httpURLConnection.setChunkedStreamingMode(0);

这应该可以解决无声重试。 错误报告和解决方法可以在这里找到

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

这篇关于停止无声重的HttpURLConnection的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆