504 gateway timeout(504网关超时问题)
场景
调用接口,提示504 gateway timeout
解决方案
一看就知道和nginx代理有关。
先看nginx配置:
location /getUser {
proxy_pass http://useApi;
client_max_body_size 200m;
proxy_connect_timeout 10;
proxy_send_timeout 120;
proxy_read_timeout 120;
}
proxy_connect_timeout 10; 这里是代理连接时间。
调整为60秒看看。
发现还是超时。
除了nginx中可以设置超时时间,代码中也可以设置。
httpClient.getParams()
.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); //连接超时10s
httpClient.getParams()
.setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000);
这里也都调高一些,问题解决。
还没有评论,来说两句吧...