Note that there are some explanatory texts on larger screens.

plurals
  1. PONginx 1.4.1 + Socket.io couldn't work. Handshake authorized but not working
    text
    copied!<p>I am using nginx 1.4.1 and I am trying to configure it with to work with socket.io websockets. I think I have done it correctly since I see a 'handshake authorized', but after a few seconds socket.io starts using xhr-polling, jsonp-polling and couldn't work.</p> <p>My node.js express app runs on localhost:3002. And I use nginx to reverse proxy to this app. Socket.io is also listening on the same port. </p> <p>I tried to follow many guides in SO and elsewhere but I just couldn't get this to work. Need some help from you experts. I've also placed by error log in here, not sure if it will help. </p> <p>nginx.conf:</p> <pre><code>upstream instaneous { server 127.0.0.1:3002; } server { listen 80; server_name instaneous.pin.gs; access_log logs/instaneous.access.log; error_log logs/instaneous.error.log; location / { 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_set_header X-NginX-Proxy true; proxy_pass http://instaneous; proxy_redirect off; # enables WS support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } } </code></pre> <p>node.js socket.io log</p> <pre><code> debug - client authorized info - handshake authorized Z7CX6-3PIUStxILeiTk3 debug - setting request GET /socket.io/1/websocket/Z7CX6-3PIUStxILeiTk3 debug - set heartbeat interval for client Z7CX6-3PIUStxILeiTk3 debug - client authorized for debug - websocket writing 1:: debug - setting request GET /socket.io/1/xhr-polling/Z7CX6-3PIUStxILeiTk3?t=1373509382625 debug - setting poll timeout debug - discarding transport debug - cleared heartbeat interval for client Z7CX6-3PIUStxILeiTk3 debug - setting request GET /socket.io/1/jsonp-polling/Z7CX6-3PIUStxILeiTk3?t=1373509392627&amp;i=0 debug - setting poll timeout debug - discarding transport debug - clearing poll timeout debug - clearing poll timeout debug - jsonppolling writing io.j[0]("8::"); debug - set close timeout for client Z7CX6-3PIUStxILeiTk3 debug - jsonppolling closed due to exceeded duration debug - setting request GET /socket.io/1/jsonp-polling/Z7CX6-3PIUStxILeiTk3?t=1373509412768&amp;i=0 debug - setting poll timeout debug - discarding transport debug - cleared close timeout for client Z7CX6-3PIUStxILeiTk3 debug - jsonppolling received data packet 5:::{"name":"join","args":["abcdef"]} { '': [ 'Z7CX6-3PIUStxILeiTk3' ], '/abcdef': [ 'Z7CX6-3PIUStxILeiTk3' ] } debug - clearing poll timeout debug - jsonppolling writing io.j[0]("8::"); debug - set close timeout for client Z7CX6-3PIUStxILeiTk3 debug - jsonppolling closed due to exceeded duration debug - client authorized info - handshake authorized BLbSS3QLgn54BThtiTk4 debug - client authorized info - handshake authorized 6TOdYiYsxIz_b19GiTk5 </code></pre> <p>instaneous.error.log</p> <pre><code>2013/07/11 04:01:49 [error] 406#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 220.255.2.143, server: instaneous.pin.gs, request: "GET /socket.io/1/xhr-polling/AFH6aS6ku3hM36qH49dI?t=1373515290708 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/xhr-polling/AFH6aS6ku3hM36qH49dI?t=1373515290708", host: "instaneous.pin.gs", referrer: "http://instaneous.pin.gs/" 2013/07/11 04:01:49 [error] 406#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 220.255.2.163, server: instaneous.pin.gs, request: "GET /socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515300709&amp;i=0 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515300709&amp;i=0", host: "instaneous.pin.gs", referrer: "http://instaneous.pin.gs/" 2013/07/11 04:01:49 [error] 406#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 220.255.2.143, server: instaneous.pin.gs, request: "POST /socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515309646&amp;i=0 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515309646&amp;i=0", host: "instaneous.pin.gs", referrer: "http://instaneous.pin.gs/" 2013/07/11 04:01:49 [error] 406#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 220.255.2.143, server: instaneous.pin.gs, request: "GET /socket.io/1/?t=1373515310157 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/?t=1373515310157", host: "instaneous.pin.gs", referrer: "http://instaneous.pin.gs/" 2013/07/11 04:01:50 [error] 406#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 220.255.2.143, server: instaneous.pin.gs, request: "GET /socket.io/1/?t=1373515311158 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/?t=1373515311158", host: "instaneous.pin.gs", referrer: "http://instaneous.pin.gs/" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload