大约17分钟后,用于Tomcat的Nginx代理终止连接

时间:2018-08-07 10:04:05

标签: java tomcat nginx

我让Nginx 1.10.2充当Spring Boot 2应用程序的反向代理,该应用程序使用在Ubuntu 16.04.1。上运行的Tomcat 8.5.28。我们的端点之一将大量数据流回客户端。经过大约17分钟的连续流传输后,Nginx似乎终止了连接。

在Java应用程序中,我得到:

org.apache.catalina.connector.ClientAbortException: java.net.SocketTimeoutException
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]
    at org.apache.catalina.connector.OutputBuffer.appendByteArray(OutputBuffer.java:785) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]
    at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:721) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]
    at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]
    at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) ~[tomcat-embed-core-8.5.28.jar!/:8.5.28]

在Nginx错误日志中:

[error] 18876#18876: *70244827 readv() failed (104: Connection reset by peer) while reading upstream, client: xxx, server: xxx, request: "GET xxx", host: "xxx"

在客户端上(卷曲):

curl: (18) transfer closed with outstanding read data remaining

我一直在使用curl和--rate-limit进行测试,以使传输速度减慢到足以花费17分钟以上的时间。如果它在17分钟内完成,或者如果我绕过Nginx并直接连接到Java应用程序,它将起作用。

Nginx虚拟主机:

upstream grouse_local {
    server 127.0.0.1:8143;
}

server {
    listen 443 ssl;
    server_name ...;
    access_log /var/log/nginx/grouse_local_access.log;
    error_log /var/log/nginx/grouse_local_error.log;
    ssl_certificate ...;
    ssl_certificate_key ...;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    gzip on;
    gzip_proxied any;
    gzip_types text/css text/plain text/xml application/xml application/javascript application/x-javascript text/javascript application/json text/x-json text/csv;
    gzip_vary on;
    gzip_min_length 1000;

    location / {
        proxy_pass http://grouse_local/;
        proxy_next_upstream error timeout http_502;
        proxy_http_version 1.1;
        set_real_ip_from ...;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

有什么想法吗?我不想在我们的API文档中添加“不要流超过17分钟”:)

0 个答案:

没有答案