Android terminal サーバ FIN to server is delayed when TCP connection is lost

Asked 1 years ago, Updated 1 years ago, 87 views

When TCP is disconnected by using the Android device application, if it is normal, after the FIN is thrown to the server 端末 terminal, the FIN is immediately returned to the terminal サーバ server.
However, sometimes it takes about 120s to return the FIN to the Terminal Server after the FIN is thrown to the Terminal.

What do you think is the reason for the delay?
Is it a problem with the operating system issue?
端末The terminal application has a socket closing process as a common process for HTTP requests

android tcp

2022-09-30 20:50

1 Answers

There is no denying the possibility of a bug in the software of the TCP protocol installed in Android OS, but
The sequence of TCP close operations is as follows:

Server: FIN (do not send data from server with this) - > ACK response (OK, OK.But the client may still send it.)
Client: FIN (do not send data from client) - > ACK response (OK OK)
Server Client: Now that both are FIN recognized, let's close it.

In other words, TCP disconnect has not been established at the time of FIN on the server->terminal (shutdown state).
Also, the server cannot send(), but recv() is possible if it is not shutdown.
The client side can send() and recv().However,
for the socket being used When the client recv(), TCP protocol side returns "no received data" and "0" as the return value (there is no possibility that the server will send it anymore).

Therefore, the possible cause of the delay in FIN from the client is
The client may not have done close() or shutdown (write) to send the FIN to the server.
Specifically, the client side is still processing incoming or outgoing (still working).
Or maybe you didn't issue close() properly due to client side application issue.
As far as I'm concerned, it takes 120 seconds, so there's a high possibility that it's a TCP protocol or something wrong with the application.
Depending on the setting, 120 seconds is a good time to cut, and the close() executed by the server may have timed out and disconnected.
You won't know until you look at the packet capture, but if the client sends data after the server times out (TIME-WAIT2->CLOSED) in close(), it should return an RST. If that's the case, there's a high possibility that the close() timeout forced disconnection.


2022-09-30 20:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.