[英]504 gateway timeout on hitting an endpoint
I am currently hitting an endpoint which returns a JSON response.我目前正在访问一个返回 JSON 响应的端点。 But sometimes when the computation time is large, its giving an 504 gateway timeout error .
但有时当计算时间很大时,它会给出504 gateway timeout error 。 below is my code snippet
下面是我的代码片段
Python Code Python代码
import json, requests
ans = requests.get(url).text
card_data = json.loads(ans)
print(card_data) # this is where response gets stored
Respone status text响应状态文本
'<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body bgcolor="white">\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>nginx/1.14.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n'
I am also wondering is there a way to configure nginx settings to increase the timeout when endpoint is hit.我还想知道有没有办法配置 nginx 设置以增加命中端点时的超时。 (I have control of the server)
(我控制了服务器)
Please suggest a workaround.请提出解决方法。
If you have Nginx
as a proxy server, you can increase the timeout
in the config file.如果你有
Nginx
作为代理服务器,你可以在配置文件中增加timeout
。
server {
...
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
...
}
But don't forget to restart the Nginx
server.但不要忘记重启
Nginx
服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.