strongloop / strong-pm

deployer for node applications
http://strong-pm.io
Other
1k stars 71 forks source link

socket.io integration #327

Closed masalinas closed 8 years ago

masalinas commented 8 years ago

I saw that I could use strong-cluster-socket.io-store but only using with the native cluster implementation.

But how can I integrate socket.io with strong-pm??, is it possible?

Regards.

sam-github commented 8 years ago

Possible, strong-pm neither helps nor hinders (what protocols you use over your HTTP port are wholly irrelevant to it). If you have a socket.io app, it will work.

masalinas commented 8 years ago

I'm testing your loopback-example-socket.io-chat test example I executed this example under strongloop-pm with two cluster nodes on 3001 port example. If execute the command slc ctl you'll see:

Service ID: 1 Service Name: loopbackchat Environment variables: No environment variables defined Instances: Version Agent version Debugger version Cluster size Driver metadata 5.0.1 2.0.2 1.0.0 2 N/A Processes: ID PID WID Listening Ports Tracking objects? CPU profiling? Tracing? Debugging? 1.1.4936 4936 0 1.1.4941 4941 1 0.0.0.0:3001 1.1.5028 5028 2 0.0.0.0:3001

I configure my chat proxy nginx server like this:

`` upstream strong_chat { ip_hash; server 127.0.0.1:3001; }

server { listen 80; server_name chat.com;

location / { proxy_pass http://strong_chat;

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_redirect off;

}

location /socket.io{ proxy_pass http://strong_chat/socket.io;

# enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

} } ``

If access to the chat app: http://chat.com

I obtain continously the error:

GET http://chat.com/socket.io/?EIO=3&transport=polling&t=1458413282501-386&sid=PkMmiwHJlcCkRNL7AAGj 400 (Bad Request) socket.io-1.2.0.js:2 WebSocket connection to 'ws://chat.com/socket.io/?EIO=3&transport=websocket&sid=BzTGqvuTeDTaNQ4nAAGf' failed: Error during WebSocket handshake: Unexpected response code: 502

If access http://chat.com:3001 (outside ngninx proxy) not exist any socket.io error

Where is the problem???

Rsgards