简体   繁体   English

HTTP 1.1持久连接:Android GET / POST:[FIN / ACK]即将到来

[英]HTTP 1.1 Persistent connection: Android GET/POST: [FIN/ACK] coming

I am consuming HTTP GET/POST request in an Android Applicaton, Its doing well(Request And response) however when i refer to wireshark LOG there is [FIN, ACK] is coming, is it means my connection is closing or what? 我在Android Applicaton中使用HTTP GET / POST请求,它表现良好(请求和响应),但是当我引用Wireshark LOG时,[FIN,ACK]即将到来,这是否意味着我的连接正在关闭或是什么? My requirement is to make the connection persistent. 我的要求是使连接持久化。 So my question is why FIN/ACK is coming and if it is closing the connection then where i am leaving? 所以我的问题是,为什么要进行FIN / ACK,如果要关闭连接,那么我要离开哪里?

WireShark LOG and Request/Response content are below: WireShark LOG和请求/响应内容如下:

For GET/POST: 对于GET / POST:

Request: 请求:

GET /api/application/addparam HTTP/1.1
Content-Type: application/json; charset=utf-8
User-Agent: okhttp/2.5.0
Authorization: Basic QURJOg==
Host: 10.92.33.190:8080
Connection: Keep-Alive

Response: 响应:

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Length: 558
Date: Fri, 18 May 2018 13:11:46 GMT
Connection: keep-alive

{
//JSON Here
}

WireShark LOG: WireShark日志:

692 28.537182   10.92.33.134    10.92.33.190    HTTP    329 POST /api/application/AddParam HTTP/1.1  (application/json)
693 28.541340   10.92.33.190    10.92.33.134    HTTP    345 HTTP/1.1 200 OK  (application/json)
704 29.194478   10.92.33.190    10.92.33.134    TCP 66  8080 → 47074 [FIN, ACK] Seq=289 Ack=334 Win=66048 Len=0 TSval=285850628 TSecr=19045098
709 29.393729   10.92.33.134    10.92.33.190    TCP 66  47074 → 8080 [ACK] Seq=334 Ack=290 Win=88832 Len=0 TSval=19045619 TSecr=285850628   
852 33.544459   10.92.33.190    10.92.33.134    TCP 66  8080 → 45502 [FIN, ACK] Seq=280 Ack=264 Win=66304 Len=0 TSval=285854978 TSecr=19045534

855 33.583848   10.92.33.134    10.92.33.190    TCP 66  45502 → 8080 [ACK] Seq=264 Ack=281 Win=88832 Len=0 TSval=19046038 TSecr=285854978

Based on the packet capture the connection close is initiated by the server shortly after the response was sent. 基于数据包捕获,在发送响应后不久,服务器将启动连接关闭。 If and how long the server is keeping the connection open for the next HTTP request within the same TCP connection solely depends on the server side and there is no way for the client to tune this. 服务器是否为同一TCP连接中的下一个HTTP请求保持打开状态的连接时间和持续时间仅取决于服务器端 ,客户端无法调整此连接。 All the client can do is to nicely ask the server to keep the connection open for another request, which you do by using HTTP/1.1 and also by sending (a redundant) Connection: keep-alive . 客户端所能做的就是很好地要求服务器为另一个请求保持连接打开状态,您可以使用HTTP / 1.1并通过发送(冗余) Connection: keep-alive来做到这一点。 There is no way for the client to enforce persistent connection or to enforce a minimum time how long the server should wait for the next request. 客户端无法强制执行持久连接或强制最小时间服务器应等待下一个请求的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM