HTTP长连接与短连接使用方法及测试详解
##Keep-Alive: timeout=60 第一次请求,与connection:close无差别 [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.conn.PoolingHttpClientConnectionManager:?) - Connection request: [route: {}->:80][total kept alive: 0; route allocated: 0 of 32; total allocated: 0 of 200] [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.conn.PoolingHttpClientConnectionManager:?) - Connection leased: [id: 0][route: {}->:80][total kept alive: 0; route allocated: 1 of 32; total allocated: 1 of 200] [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.execchain.MainClientExec:?) - Opening connection {}->:80 ## 客户端设置超时时间60s [2017-04-26 10:57:00 DEBUG] (org.apache.http.wire:?) - http-outgoing-0 >> "Connection: keep-alive[r][n]" [2017-04-26 10:57:00 DEBUG] (org.apache.http.wire:?) - http-outgoing-0 >> "Keep-Alive: timeout=60[r][n]" ## 服务端设置超时时间5s [2017-04-26 10:57:00 DEBUG] (org.apache.http.wire:?) - http-outgoing-0 << "Keep-Alive: timeout=5, max=100[r][n]" [2017-04-26 10:57:00 DEBUG] (org.apache.http.wire:?) - http-outgoing-0 << "Connection: Keep-Alive[r][n]" ## 服务端设置生效,连接可以保持5s [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.execchain.MainClientExec:?) - Connection can be kept alive for 5000 MILLISECONDS [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.conn.PoolingHttpClientConnectionManager:?) - Connection [id: 0][route: {}->:80] can be kept alive for 5.0 seconds [2017-04-26 10:57:00 DEBUG] (org.apache.http.impl.conn.PoolingHttpClientConnectionManager:?) - Connection released: [id: 0][route: {}->:80][total kept alive: 1; route allocated: 1 of 32; total allocated: 1 of 200] ##Keep-Alive: timeout=60 非第一次请求 [2017-04-26 14:11:00 DEBUG] (org.apache.http.impl.conn.PoolingHttpClientConnectionManager:?) - Connection request: [route: {}->:80][total kept alive: 1; route allocated: 1 of 32; total allocated: 1 of 200] ## 连接在上一次请求结束后5s失效 [2017-04-26 14:11:00 DEBUG] (org.apache.http.impl.conn.CPool:?) - Connection [id:2][route:{}->:80][state:null] expired @ Wed Apr 26 14:10:05 GMT+08:00 2017 客户端设置失效时间,服务端设置不失效 (编辑:西安站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |