首页 > 其他分享 >504 gateway timeout 两种 情况与解决方案

504 gateway timeout 两种 情况与解决方案

时间:2022-12-14 18:39:03浏览次数:42  
标签:http log 300 nginx proxy timeout 504 gateway


HttpClient 

客户端访问服务器,产生的超时现象

client HttpClient(connectionTimeout, socketTimeout) -> server

若socketTimeout<server响应时间,则报异常Read timed out(java.lang.Exception: Read timed out);

conectionTimeout:连接建立的时间(tcp三次握手时间);

socketTimeout:等待数据的时间或者两个包之间的间隔时间;

解决方案:

这个很简单,只需要增加到连接时间和数据读取时间即可。

post(String url, String body, String mimeType, String charset, Integer connTimeout, Integer readTimeout)

Nginx

一般这种后端为tomcat,nginx代理报504超时错误。

解决方案如下:

全局修改:

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile on;
    #tcp_nopush on;

    keepalive_timeout 65;

    #gzip on;

    include /etc/nginx/conf.d/*.conf;
    #用于tomcat反向代理,解决nginx 504错误 
    proxy_connect_timeout 300; #单位秒 
    proxy_send_timeout 300; #单位秒 
    proxy_read_timeout 300; #单位秒 
    proxy_buffer_size 16k; 
    proxy_buffers 4 64k; 
    proxy_busy_buffers_size 128k; 
    proxy_temp_file_write_size 128k;
    # ps:以timeout结尾配置项时间要配置大点
}

只对 修改server{}

location / {
proxy_pass http://182.61.131.62:33060/;
proxy_redirect off;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_connect_timeout 300;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

标签:http,log,300,nginx,proxy,timeout,504,gateway
From: https://blog.51cto.com/u_15461374/5938146

相关文章

  • gateway动态路由实现 mysql+redis 实现
    前言大家都知道咱们在通常是使用配置文件来实现配置,但是这样就有一个弊端,就是每次修改的时候都要去重启来实现,并且管理起来非常麻烦,所有就有了这种实现方式。现在的实现方式......
  • Gateway服务网关的介绍与使用
    什么是服务网关传统的单体架构中只需要开放一个服务给客户端调用,但是微服务架构中是将一个系统拆分成多个微服务,如果没有网关,客户端只能在本地记录每个微服务的调用地址,当需......
  • Gateway 代理日志记录 Filter
    前言我们在使用网关的时候,有时候客户端会有莫名其妙的问题需要服务端辅助定位,这时候有一份完全的请求的信息的日志会非常有帮助,这里提供一种基于过滤器的实现方式。我的实......
  • asp.net core 微服务网关示例 ocelot gateway Demo
    ocelotasp.netcore微服务gateway介绍https://ocelot.readthedocs.io/en/latest/introduction/gettingstarted.html 1.新建asp.netcorewebapi空项目AProject,nug......
  • spring-cloud-alibaba-整合spring-clouid-gateway-3.1.4
    spring-cloud-alibaba-整合spring-clouid-gateway-3.1.4spring-cloud-alibaba-整合spring-clouid-gateway-3.1.4前言版本说明引入spring-cloud-gatewayspring-cloud......
  • Zuul和Gateway
    Zuul是Netflix公司提供的微服务网关,它可以和Eureka、Ribbon、Hystrix等组件配合使用,实现认证和安全、性能监测、动态路由、负载均衡、压力测试、静态资源处理等功能。Gate......
  • @Order和Ordered在gateway中的异常情况
    使用场景多个过滤器时,确定执行的先后顺序.注意是过滤器执行的先后顺序,不是加载的先后顺序值越小,越先执行@ComponentpublicclassGlobalLogFilterimplementsGloba......
  • The XML for Analysis request timed out before it was completed. Timeout value: 1
        数据源错误:TheXMLforAnalysisrequesttimedoutbeforeitwascompleted.Timeoutvalue:18000sec.群集URI:WABI-EAST-ASIA-A-PRIMARY-redirect......
  • Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Time
    遇到问题:今天在启动kafka后创建topic时遇到如下错误:[root@localhostconfig]#kafka-topics.sh--create--zookeeper192.168.68.110:2181,192.168.68.111:2181,192.16......
  • BOOT TIMEOUT: forcing display enabled
     ​​http://stackoverflow.com/questions/31618101/android-custom-launcher-doesnt-stop-the-bootanimation​​问题描述:新开发的launcher,启动后20s左右没有反应,查看打......