Android http keepalive solution, but is it permanent?

I have a search button that accesses the server every time I click it. The problem is that if I click it several times in a row, it will work fine. However, if I wait 5 seconds, the first press will not work. He simply does not receive an answer. The second press will work, and the subsequent button presses until I withstand a certain amount of time (~ 5 seconds)

So, if you are constantly looking for new things for 5 seconds, your first press of a button will do nothing.

This is solved using

          System.setProperty("http.keepAlive", "false");

However, I read that this eliminates persistent connections when a new TCP connection should be made every time I click on this button. It is slower, but it is not buggy.

Is this a bad decision? I read that it doesn’t fix anything. I would like to help, thanks.

+5
source share
2 answers

You said:

However, if I wait 5 seconds, the first press will not work. He simply does not receive an answer.

I think the server did not even receive the request in your case. I think setting http.keepAlive to false is a good fix. I spent a lot of time studying this problem, and it is more than obvious that this is a bug in the Android library.

, , - , . , Android, .

http.keepAlive , , HTTP, .

+4

ClientConnectionManager , ManagedClientConnection. . .

org.apache.http.conn

0

All Articles