开发者

Lost http request

开发者 https://www.devze.com 2023-04-10 04:22 出处:网络
I am writing an android application, and use the following line of code in my application, httpClient.execute(httpPost);

I am writing an android application, and use the following line of code in my application,

httpClient.execute(httpPost);

I have verified through the debugger, that neither the httpClient, nor the httpPost are null. Yet sometimes, even in the presence of a wifi connection, the above line does execute, but the server is no开发者_如何学Ct hit. What could be the cause of this problem?

Moreover, weirdly, there are three such calls in my code. The first two work, the last one dose not. However, if I replace the second call, with a dummy call to google, then the third call works!

Regards


You can send a HTTP request from a background thread too, in fact best practice is to do so as you don't want to wait for a response on the UI thread.

If you get no error messages - and you're not handling it with a do-nothing catch clause, then the problem is either in the server's code not showing you the request, or in the network. If it's a remote server, you may have a problem with a proxy or firewall. You could do some packet capturing with tcpdump, wireshark for Android. Or route your traffic through a PC to see network activity on a larger screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号