alexanoid
alexanoid

Reputation: 25770

Tomcat, NGINX, Vaadin, Spring Boot and LONG POLLING Push

I'm trying to properly configure LONG POLLING push with Vaadin (Java, Spring Boot), NGINX and Tomcat.

Sometimes Push stops working, and I suspect it may be the reason of some misconfiguration in my setup.

The issue:

Push unexpectedly stops working until the page is hard-refreshed with F5. The key point here is the unexpected nature of the issue. However, plain XHR requests continue to work fine. Currently, Vaadin team are working to verify everything on the Vaadin/Atmosphere side. Alongside that, I would like to check if the system configuration for LONG POLLING is correct.

Could you please verify my configuration for issues (especially timeouts, buffers, etc):

Vaadin/Spring Boot/Tomcat config:

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 config:

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; 
    }


}

I also added following sysctl properties to the Linux:

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

Upvotes: 0

Views: 354

Answers (0)

Related Questions