504 gateway timeout (504 gateway timeout problem)

Scenes

Call the interface, prompt 504 gateway timeout

solution

At a glance, it is related to the nginx proxy.

First look at the nginx configuration:

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; Here is the proxy connection time.
Adjust it to 60 seconds to see.
It is still timed out.

In addition to the timeout period that can be set in nginx, it can also be set in the code.

httpClient.getParams()
.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); //连接超时10s

httpClient.getParams()
.setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000);  

Here are all adjusted higher, the problem is solved.

Guess you like

Origin blog.csdn.net/enthan809882/article/details/113936034