在开发新浪微博的时候,遇到了“The target server failed to respond”这个错误。 通过遍地搜索,在GoogleIssueEvery time my application is started it takes upwards to a minute for HTTPS Post(via http proxy) to return results ( See code below). Once the first Post returns results, all following requests seem to return at a reasonable speed. I reuse the androidHttpClient, and after about three minute passed, the next HTTPS Post request to server hangs long again. The problem is not on the server side since HTTPS Post to the server(via http proxy) in another platform(window mobile/s60/iphone) return results not hanging so long. System: Running on device vodafon, HTC Magic 2.1-update1. Sample code that causes the problem: static AndroidHttpClient androidHttpClient = null; public String sendRequest(String strReqData, String strUrl, Context context) { String strResponse = null; ArrayList<BasicNameValuePair> pairs = new ArrayList<BasicNameV
Android4.0之前HttpClient的问题The target server failed to respond
最新推荐文章于 2023-02-14 17:12:08 发布
在开发过程中遇到一个错误:'The target server failed to respond',主要出现在Android 4.0之前的版本。问题可能不是由于服务器端,而是AndroidHttpClient在HTTPS Post请求时响应延迟。解决方案包括:1) 使用丑陋的hack方法防止Android Honeycomb及更早版本的反向DNS查找bug;2) 考虑切换到HttpURLConnection,尤其是在Froyo之后的版本中,它已经成为更好的选择。

最低0.47元/天 解锁文章
1120

被折叠的 条评论
为什么被折叠?



