Python:requests.session无法使连接保持活动状态

时间:2019-11-18 09:03:58

标签: python nginx python-requests keep-alive

我的客户不断向nginx服务器发送http请求,试图通过request.Session建立的保持链接。但是nginx的error.log显示我的客户端不断关闭链接。

这里是发件人。实际上,我的客户端是一台应用服务器,不断向Nginx发送性能统计信息。

# Init the keep-alived connection when booting the application server
def global_init():
  .......
  global s_perf
  s_perf = requests.Session()

#Send performance statistic
def perf(message):
  s_perf.post('http://127.0.0.1:8180/perf', data=message)

Nginx正确接收了这些统计信息。但是logs / error.log显示该链接经常关闭:

2019/11/18 17:01:43 [info] 61987#61987: *11945220 client 10.32.170.17 closed keepalive connection
2019/11/18 17:01:43 [info] 61992#61992: *11943901 client 10.32.170.17 closed keepalive connection
2019/11/18 17:01:43 [info] 61964#61964: *11945149 client 10.32.170.17 closed keepalive connection
2019/11/18 17:01:43 [info] 61955#61955: *11945286 client 10.32.170.17 closed keepalive connection
2019/11/18 17:01:43 [info] 61973#61973: *11944762 client 10.32.170.17 closed keepalive connection
2019/11/18 17:01:43 [info] 61985#61985: *11945354 client 10.32.170.17 closed keepalive connection

0 个答案:

没有答案