You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin+Spring Boot+Tomcat+NGINX环境下长轮询推送(LONG POLLING Push)异常问题排查及配置验证请求

Vaadin+Spring Boot+Tomcat+NGINX环境下长轮询推送(LONG POLLING Push)异常问题排查及配置验证请求

大家好,我正在给Vaadin(Java+Spring Boot)、NGINX和Tomcat的组合环境配置长轮询推送,但最近遇到了挺头疼的问题,想请各位帮忙看看我的配置有没有问题,尤其是超时、缓冲区这类和长轮询相关的设置。

问题描述

  • 推送会毫无征兆地停止工作,必须按F5硬刷新页面才能恢复,但普通的XHR请求一直是正常的。目前Vaadin团队正在排查Atmosphere和Vaadin本身的问题,不过我也想确认一下系统层面的长轮询配置是否存在疏漏。
  • 用iPhone访问的时候,每天都会遇到好几次这个问题,有时候甚至F5刷新都没用,必须手动断开Wi-Fi,切换到LTE网络后应用才立刻恢复正常。感觉像是有什么东西导致了应用被“锁定”一样。

下面是我的各项配置,麻烦大家帮忙检查是否有潜在问题:

一、Vaadin/Spring Boot/Tomcat 配置

server.servlet.session.persistent=false
server.servlet.session.timeout=30m
server.servlet.session.tracking-modes=cookie
server.servlet.session.cookie.http-only=true
server.servlet.session.cookie.secure=true
server.servlet.session.cookie.max-age=365d
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=common
vaadin.whitelisted-packages=com.vaadin,org.vaadin,com.examle
vaadin.heartbeatInterval=30
vaadin.pushLongPollingSuspendTimeout=25000
vaadin.maxMessageSuspendTimeout=5000
vaadin.closeIdleSessions=false
vaadin.eagerServerLoad=false

二、NGINX 配置

server {
    sendfile                   on;
    tcp_nodelay                on;
    tcp_nopush                 on;
    etag                       off;
    if_modified_since          off;
    proxy_buffering            off;
    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k;
    proxy_cache                off;
    proxy_cache_convert_head   off;
    proxy_max_temp_file_size   0;
    client_max_body_size       0;
    proxy_http_version         1.1;
    proxy_pass_request_headers on;
    proxy_pass_request_body    on;
    proxy_read_timeout         300;
    proxy_connect_timeout      300;
    proxy_send_timeout         300;
    reset_timedout_connection  on;
    proxy_redirect             off;
    resolver                   77.88.8.8 77.88.8.1 8.8.8.8 8.8.4.4 valid=1d;

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types
        application/atom+xml
        application/geo+json
        application/javascript
        application/x-javascript
        application/json
        application/ld+json
        application/manifest+json
        application/rdf+xml
        application/rss+xml
        application/xhtml+xml
        application/xml
        font/eot
        font/otf
        font/ttf
        image/svg+xml
        text/css
        text/javascript
        text/plain
        text/xml;

    location / {
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Frame-Options "ALLOW-FROM blog.example.com";
        add_header Access-Control-Allow-Origin example.com;
        add_header Access-Control-Allow-Origin blog.example.com;
        add_header Content-Security-Policy "frame-ancestors example.com blog.example.com";

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_read_timeout     300;
        proxy_connect_timeout  300;
        proxy_send_timeout     300;

        include /etc/nginx/snippets/cors.conf;

        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

三、Linux sysctl 配置

sysctl -w net.ipv4.tcp_retries2=5
sysctl -w net.ipv4.tcp_keepalive_time=300
sysctl -w net.ipv4.tcp_keepalive_intvl=1
sysctl -w net.ipv4.tcp_keepalive_probes=5

麻烦各位帮忙看看这些配置里有没有可能引发推送异常的地方,比如超时设置不匹配、缓冲区配置不合理之类的,非常感谢大家的帮助!

备注:内容来源于stack exchange,提问作者alexanoid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:50:28