ANN: Socket.IO-test.com - problem with NGINX and websockets

1118 views
Skip to first unread message

Chris Dew

unread,
Jun 10, 2013, 4:16:29 AM6/10/13
to sock...@googlegroups.com
I've just written a little utility called "Socket.IO Test" - http://Socket.IO-test.com

It's very rough around the edges.  In particular I'm having trouble using NGINX to proxy websockets.  It's worse than not working, it just stalls and so Socket.IO does not fail over to a different transport.

chris@proliant:~$ cat /etc/nginx/sites-enabled/socket.io-test.com 
server {
  server_name socket.io-test.com;

  proxy_pass http://localhost:8011;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";

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

If I can't solve it in a week or two, I'll just buy a new server and run it without a proxy.

Later roadmap changes include introducing HTTPS tests.

Help appreciated,

Chris.

Arnout Kazemier

unread,
Jun 10, 2013, 4:36:54 AM6/10/13
to sock...@googlegroups.com
Make sure you have the latest nginx installed and have the correct timeouts configured.
I've got some example configurations over at https://github.com/observing/balancerbattle
that you might find useful.

- Arnout
--
You received this message because you are subscribed to the Google Groups "Socket.IO" group.
To unsubscribe from this group and stop receiving emails from it, send an email to socket_io+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Dew

unread,
Jun 10, 2013, 4:52:03 AM6/10/13
to sock...@googlegroups.com
Error was: 502 Bad Gateway from NGINX (found using wireshark)

All other (proxied) traffic on port 80 is fine, including non-websocket transports.

chris@proliant:~$ nginx -V
nginx version: nginx/1.5.0
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.5.0/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.5.0/debian/modules/nginx-dav-ext-module --add-module=/build/buildd/nginx-1.5.0/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.5.0/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.5.0/debian/modules/ngx_http_substitutions_filter_module

I've also added timeouts now:

chris@proliant:~$ cat /etc/nginx/sites-enabled/socket.io-test.com 
server {
  server_name socket.io-test.com;

  proxy_pass http://localhost:8011;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";

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

  #
  # Specific for comet or long running HTTP requests, don't buffer up the
  # response from origin servers but send them directly to the client.
  #
  proxy_buffering     off;

  #
  # Bump the timeout's so someting sensible so our connections don't
  # disconnect automatically. We've set it to 12 hours.
  #
  proxy_connect_timeout 43200000;
  proxy_read_timeout    43200000;
  proxy_send_timeout    43200000;

Chris Dew

unread,
Jun 13, 2013, 4:41:12 PM6/13/13
to sock...@googlegroups.com
Downgrading to from NGINX 1.5.0 to 1.4.1 fixed the issue, so I'm guessing an NGINX bug (though I also made a minor change to the config, as 1.4.1 was unhappy with various 'proxy' statements in the server block - I moved them into a "location /" block).

Anyway, http://socket.io-test.com is now available for you to test your clients' browsers and dodgy firewalls and proxies.

All the best,

Chris.

Elvio Rogelio Toccalino

unread,
Jun 13, 2013, 4:43:42 PM6/13/13
to sock...@googlegroups.com

Thanks Chris, this will be super useful.

Reply all
Reply to author
Forward
0 new messages