My javascript game application will not work when I use pm2 start process.yml
. The game works just fine when I use npm start
but not pm2 start process
. The index.js file on server loads but then gives me errors such as:
WebSocket connection to 'ws://www.zeyeland.com:3000/socket.io/?EIO=3&transport=websocket&sid=gwcGq7h5vHrxBGOyAAAA' failed: WebSocket is closed before the connection is established.
and
GET http://www.zeyeland.com:3000/socket.io/?EIO=3&transport=polling&t=MEzN2OK&sid=gwcGq7h5vHrxBGOyAAAA 400 (Bad Request)
Once again my program runs smoothly when I start my server using npm start
.
Here is my process.yml file
apps:
- script: node index.js
watch: true
instances: 4
exec_mode: cluster
env:
NODE_ENV: development
env_production:
NODE_ENV: production
package.json
{
"name": "sockets",
"version": "0.0.1",
"description": "web sockets demo",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.16.3",
"socket.io": "^2.1.1"
}
}
What can be the problem? Does it have something to do with my apache2 reverseProxy? I was getting a similar error earlier on when I attempted to configure my reverse proxy for nodejs app running on zeyeland:3000 to zeyeland/bomber-kids-online.
The code I added to my .bashrc file on my server to configure my pm2 clusters is
cd /var/www/html/bomber-kids && pm2 start process.yml && cd ~
When I run pm2 start process.yml
, the clusters start and everything appears to be working until I access websites, and then the game gives a console error due to socket issues.