我正在apache airflow作业中进行python服务调用,POST调用是直接的,但在5分钟后,它失败了,并出现此错误"远程端闭合连接而没有响应";。
res = requests.post(url, verify=False, auth=token) //The server responds in 5 to 10 minutes after it process few items
注意:使用";CURL";命令持续 8分钟后收到响应
我想知道是谁在关闭连接?是客户端、服务器端还是Apache气流?由于CURL命令运行良好,服务器端似乎也不错。我需要更改我的客户端python请求调用超时等还是Apache气流侧的更改?
我使用TCPKeepAliveAdapter使其工作。这是现在的代码,
import requests
from requests_toolbelt.adapters.socket_options import TCPKeepAliveAdapter
session = requests.Session()
keep_alive = TCPKeepAliveAdapter(idle=120, count=120, interval=60)//We are telling server that am alive.After 2 minutes it starts pinging server 120 times with 1 minute interval.
session.mount("https://", keep_alive)
res = session.post(url, verify=False, auth=token))