5

I'm running a couple of sails.js backend instances behind an nginx proxy with sticky sessions.

I keep seeing a lot of messages in my nginx error.log regarding sails.js /socket.io/ URLs timing out:

2016/01/04 20:55:15 [error] 12106#12106: *402088 upstream timed out (110: Connection timed out) while reading response header from upstream, client: x.x.x.x, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1451930055065-4&sid=jvekCYDAcFfu0PLdAAL6 HTTP/1.1", upstream: "http://127.0.0.1:3001/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1451930055065-4&sid=jvekCYDAcFfu0PLdAAL6", host: "example.com", referrer: "https://example.com/languageExchange/chat/63934"

2016/01/04 20:55:17 [error] 12105#12105: *402482 upstream prematurely closed connection while reading response header from upstream, client: y.y.y.y, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=QnAe1jiKEHgj-zlKAAKu HTTP/1.1", upstream: "http://127.0.0.1:3001/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=QnAe1jiKEHgj-zlKAAKu", host: "example.com"

2016/01/04 22:32:33 [error] 12107#12107: *437054 no live upstreams while connecting to upstream, client: z.z.z.z, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8G2TfOsNOJMYHZOjAAD3 HTTP/1.1", upstream: "http://sails/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8G2TfOsNOJMYHZOjAAD3", host: "example.com"

It doesn't happen for every client, but the number of such messages is significant. And sails.js does not show any relevant errors.

How should I investigate the nature of these issues?

Here's what I've tried so far (and it didn't help):

  • Upgrade socket.io client to the latest version so far (1.3.7)
  • Explicitly turn off caching for /socket.io/ requests in nginx

Here's the relevant config files:

sails sockets.js:

adapter: 'socket.io-redis'

nginx:

    location ^~ /socket.io/ {
        proxy_pass http://sails;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_no_cache true;
        proxy_cache_bypass true;
        proxy_redirect off;
        proxy_intercept_errors off;
}
serjrd
  • 81
  • 5
  • I've the same problem. Do you have any solution?. Thanks – pablovilas May 15 '16 at 00:50
  • Hitting the same issue, no idea where the error is or why. For now I have assumed I dont have enough connections allowed in the nginx worker. I've increased the limit from 512 to 2000 for now to see if this helps. – munkee Jul 06 '16 at 09:21
  • 1
    For anyone searching I noticed similar issues on none sail.js project which someone found a fix for: http://serverfault.com/questions/778814/websocket-reverse-proxy-with-nginx-error-about-request-in-server-log-but-works – munkee Jul 11 '16 at 10:59

0 Answers0