Open boygiandi opened 4 years ago
Hi. I am having the same problem in an AWS EC2 environment
2020-03-27T14:51:50: PM2 log: Launching in no daemon mode
2020-03-27T14:51:50: PM2 log: [Watch] Start watching smadol
2020-03-27T14:51:50: PM2 log: App [smadol:0] starting in -fork mode-
2020-03-27T14:51:50: PM2 log: App [proxy:1] starting in -fork mode-
2020-03-27T14:51:50: PM2 log: App [smadol:0] online
2020-03-27T14:51:50: PM2 log: App [proxy:1] online
@colyseus/proxy listening at {"address":"::","family":"IPv6","port":8081}
Running on ws://localhost:3000
LISTEN add { processId: 'yOncuSTFq', address: '172.31.26.198:3000' }
Using proxy 0 /matchmake/joinOrCreate/place
PlaceRoom created!
Room is at proxy 0
place closed and saved
Using proxy 0 /matchmake/joinOrCreate/place
PlaceRoom created!
Room is at proxy 0
Using proxy 0 /matchmake/joinOrCreate/place
Room is at proxy 0
Proxy error during: /yOncuSTFq/5d7f7dbb7fa1810ad880b62c?sessionId=Wyrx5AICu
Error: socket hang up
at connResetException (internal/errors.js:604:14)
at Socket.socketCloseListener (_http_client.js:400:25)
at Socket.emit (events.js:323:22)
at TCP.<anonymous> (net.js:668:12)
place closed and saved
Proxy error during: /yOncuSTFq/5db44ac9d2303724dcebc330?sessionId=YRc1NPxo0
Error: socket hang up
at connResetException (internal/errors.js:604:14)
at Socket.socketCloseListener (_http_client.js:400:25)
at Socket.emit (events.js:323:22)
at TCP.<anonymous> (net.js:668:12)
Proxy error during: /yOncuSTFq/5db44ac9d2303724dcebc330?sessionId=aEBXNdal6
Error: socket hang up
at connResetException (internal/errors.js:604:14)
at Socket.socketCloseListener (_http_client.js:400:25)
at Socket.emit (events.js:323:22)
at TCP.<anonymous> (net.js:668:12)
For production envirioment the HTTP Proxy has no response for OPTIONS requests, so its will give us Cors error. See it there: https://github.com/http-party/node-http-proxy/issues/872
My temp solution:
const reqHandler = (req: http.IncomingMessage, res: http.ServerResponse) => {
if (req.method === 'OPTIONS') {
res.setHeader('access-control-allow-origin', '*');
res.setHeader('access-control-allow-credentials', 'true');
res.setHeader('access-control-allow-methods', '*');
res.setHeader('access-control-allow-headers', '*');
res.setHeader('access-control-max-age', 60 * 60 * 24 * 30);
res.statusCode = 200;
res.end();
return;
}
const proxy = getProxy(req.url!);
if (proxy) {
proxy.web(req, res);
} else {
console.error('No proxy available!', processIds);
}
};
After resolve this, i found another problem.
the increment_var in ecosystem.config.js does not increment.
now I must pm2 kill
then pm2 start
every time.
https://github.com/Unitech/pm2/issues/4502
[EDIT] Another problem. After rerun, the old instance data keep in Redis. So the proxy try to access the old instance, then we will had the ECCONREFUSED error
[EDIT 2] to clean Redis cache in CI i used:
npm install -g redis-cli
rdcli -u ${REDIS_URL} flushall
Hi. I am having the same problem in an AWS EC2 environment
2020-03-27T14:51:50: PM2 log: Launching in no daemon mode 2020-03-27T14:51:50: PM2 log: [Watch] Start watching smadol 2020-03-27T14:51:50: PM2 log: App [smadol:0] starting in -fork mode- 2020-03-27T14:51:50: PM2 log: App [proxy:1] starting in -fork mode- 2020-03-27T14:51:50: PM2 log: App [smadol:0] online 2020-03-27T14:51:50: PM2 log: App [proxy:1] online @colyseus/proxy listening at {"address":"::","family":"IPv6","port":8081} Running on ws://localhost:3000 LISTEN add { processId: 'yOncuSTFq', address: '172.31.26.198:3000' } Using proxy 0 /matchmake/joinOrCreate/place PlaceRoom created! Room is at proxy 0 place closed and saved Using proxy 0 /matchmake/joinOrCreate/place PlaceRoom created! Room is at proxy 0 Using proxy 0 /matchmake/joinOrCreate/place Room is at proxy 0 Proxy error during: /yOncuSTFq/5d7f7dbb7fa1810ad880b62c?sessionId=Wyrx5AICu Error: socket hang up at connResetException (internal/errors.js:604:14) at Socket.socketCloseListener (_http_client.js:400:25) at Socket.emit (events.js:323:22) at TCP.<anonymous> (net.js:668:12) place closed and saved Proxy error during: /yOncuSTFq/5db44ac9d2303724dcebc330?sessionId=YRc1NPxo0 Error: socket hang up at connResetException (internal/errors.js:604:14) at Socket.socketCloseListener (_http_client.js:400:25) at Socket.emit (events.js:323:22) at TCP.<anonymous> (net.js:668:12) Proxy error during: /yOncuSTFq/5db44ac9d2303724dcebc330?sessionId=aEBXNdal6 Error: socket hang up at connResetException (internal/errors.js:604:14) at Socket.socketCloseListener (_http_client.js:400:25) at Socket.emit (events.js:323:22) at TCP.<anonymous> (net.js:668:12)
I got the same error in my production env. I deploy the @colyseus/proxy service in a docker swarm cluster after a nginx reverse proxy.
@MateusMendesSantana have you solved your problem and do you has the same deployment with me?
When I run this proxy, I get this error
I tried to fix it and I found this, if I replace the target in original code, from this
to this
It works. I don't really understand why. Maybe you can help me explain it. I fixed the code in my case, and I also replace the backend to localhost if it's the same with proxy IP.