Unable to connect with socket.io using node.js and nginx -
i've set socket.io node.js running behind nginx. main domain running on nginx , sub-domain being proxied node.js. rest apis working fine, when comes socket connections, see handshake in logs, client not able response apparently. below log node.js, , further below configs i'm using. ideas why it's not working?
info - handshake authorized 7wtmdkry1tpb97corlj4 debug - setting request /socket.io/1/websocket/7wtmdkry1tpb97corlj4 debug - set heartbeat interval client 7wtmdkry1tpb97corlj4 debug - client authorized debug - websocket writing 1:: debug - clearing poll timeout debug - jsonppolling writing io.j[0]("8::"); debug - set close timeout client jodwovtvlg7sdypnrlj2 debug - jsonppolling closed due exceeded duration debug - setting request /socket.io/1/xhr-polling/7wtmdkry1tpb97corlj4?t=1368925686996 debug - setting poll timeout debug - discarding transport debug - cleared heartbeat interval client 7wtmdkry1tpb97corlj4 debug - setting request /socket.io/1/jsonp-polling/7wtmdkry1tpb97corlj4?t=1368925696997&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 client 7wtmdkry1tpb97corlj4 debug - jsonppolling closed due exceeded duration debug - setting request /socket.io/1/jsonp-polling/7wtmdkry1tpb97corlj4?t=1368925717060&i=0 debug - setting poll timeout debug - discarding transport debug - cleared close timeout client 7wtmdkry1tpb97corlj4 debug - clearing poll timeout debug - jsonppolling writing io.j[0]("8::"); debug - set close timeout client 7wtmdkry1tpb97corlj4 debug - jsonppolling closed due exceeded duration debug - setting request /socket.io/1/jsonp-polling/7wtmdkry1tpb97corlj4?t=1368925737199&i=0 debug - setting poll timeout debug - discarding transport debug - cleared close timeout client 7wtmdkry1tpb97corlj4 debug - fired close timeout client jodwovtvlg7sdypnrlj2 info - transport end (close timeout)
nginx config:
upstream app_yourdomain { server 127.0.0.1:3000; } # nginx server instance server { listen 80; server_name mydomain.com; # pass request node.js server correct headers , more can added, see nginx config options 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_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; tcp_nodelay on; proxy_pass http://app_yourdomain/; proxy_redirect off; } }
socket.io running in 127.0.0.1:3000.
are running new enough version of nginx? websocket support introduced in nginx version 1.3.13. nginx -v
see version have. see https://chrislea.com/2013/02/23/proxying-websockets-with-nginx/
Comments
Post a Comment