2

nginx 1.4.1 を使用しており、socket.io websockets で動作するように構成しようとしています。「ハンドシェイクが承認されました」と表示されたので、正しく実行したと思いますが、数秒後にsocket.ioがxhr-polling、jsonp-pollingの使用を開始し、機能しませんでした。

私の node.js Express アプリは localhost:3002 で実行されます。そして、nginx を使用して、このアプリへのプロキシをリバースします。Socket.io も同じポートでリッスンしています。

SOや他の場所で多くのガイドに従おうとしましたが、これを機能させることができませんでした. 専門家の助けが必要です。エラーログもここに配置しましたが、役立つかどうかはわかりません。

nginx.conf:

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

        }

node.js socket.io ログ

   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&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&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

瞬間的な.error.log

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&i=0 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515300709&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&i=0 HTTP/1.1", upstream: "http://127.0.0.1:3002/socket.io/1/jsonp-polling/AFH6aS6ku3hM36qH49dI?t=1373515309646&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/"
4

0 に答える 0