Trying to host Geckos example on Heroku

I’m trying to test out the Geckos example from https://github.com/geckosio/phaser3-multiplayer-game-example

It runs fine locally but when pushed to Heroku the client crashes with the following error:

at=error code=H10 desc="App crashed" method=GET path="/" host=young-shelf-51270.herokuapp.com request_id=8f3df9e9-7504-4372-a0af-e7ac9e6ece7c fwd="49.185.11.69" dyno= connect= service= status=503 bytes= protocol=https

I was able to run this sockets tutorial project on Heroku with no problem. This geckos example does some things very differently to that.

Actually, there appears to be more to the problem than I first noticed. I think the part I posted above is just what happens when a client tries to connect. All this takes place during the build process.

It was complaining about missing ‘npm-run-all’ but I fixed that by running npm install --save npm-run-all and then copying npm-run-all from devDependencies to dependencies.

2020-09-03T11:50:23.219252+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 server:serve: `nodemon --delay 500ms server/server.js`
2020-09-03T11:50:23.220364+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-09-03T11:50:23.221435+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:23.222519+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 server:serve script.
2020-09-03T11:50:23.223600+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:23.242345+00:00 app[web.1]: 
2020-09-03T11:50:23.242348+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:23.242348+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_23_236Z-debug.log
2020-09-03T11:50:23.248693+00:00 app[web.1]: ERROR: "parcel:serve" exited with 1.
2020-09-03T11:50:23.262293+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:23.262597+00:00 app[web.1]: npm ERR! errno 1
2020-09-03T11:50:23.265144+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 dev: `npm-run-all --parallel parcel:serve server:serve`
2020-09-03T11:50:23.265237+00:00 app[web.1]: npm ERR! Exit status 1
2020-09-03T11:50:23.265363+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:23.265475+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 dev script.
2020-09-03T11:50:23.265545+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:23.272417+00:00 app[web.1]: 
2020-09-03T11:50:23.272612+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:23.272739+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_23_266Z-debug.log
2020-09-03T11:50:23.281937+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:23.282360+00:00 app[web.1]: npm ERR! errno 1
2020-09-03T11:50:23.284895+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 start: `npm run dev`
2020-09-03T11:50:23.285052+00:00 app[web.1]: npm ERR! Exit status 1
2020-09-03T11:50:23.285210+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:23.285363+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 start script.
2020-09-03T11:50:23.285518+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:23.290989+00:00 app[web.1]: 
2020-09-03T11:50:23.291184+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:23.291284+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_23_287Z-debug.log
2020-09-03T11:50:23.369110+00:00 heroku[web.1]: Process exited with status 1
2020-09-03T11:50:23.411915+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-03T11:50:23.415685+00:00 heroku[web.1]: State changed from crashed to starting
2020-09-03T11:50:28.894182+00:00 heroku[web.1]: Starting process with command `npm start`
2020-09-03T11:50:32.373875+00:00 app[web.1]: 
2020-09-03T11:50:32.373890+00:00 app[web.1]: > phaser3-multiplayer-example-with-geckos.io@1.0.0 start /app
2020-09-03T11:50:32.373891+00:00 app[web.1]: > npm run dev
2020-09-03T11:50:32.373891+00:00 app[web.1]: 
2020-09-03T11:50:33.437095+00:00 app[web.1]: 
2020-09-03T11:50:33.437107+00:00 app[web.1]: > phaser3-multiplayer-example-with-geckos.io@1.0.0 dev /app
2020-09-03T11:50:33.437108+00:00 app[web.1]: > npm-run-all --parallel parcel:serve server:serve
2020-09-03T11:50:33.437109+00:00 app[web.1]: 
2020-09-03T11:50:33.999512+00:00 app[web.1]: 
2020-09-03T11:50:33.999521+00:00 app[web.1]: > phaser3-multiplayer-example-with-geckos.io@1.0.0 parcel:serve /app
2020-09-03T11:50:33.999524+00:00 app[web.1]: > parcel serve index.html --no-source-maps
2020-09-03T11:50:33.999524+00:00 app[web.1]: 
2020-09-03T11:50:34.008451+00:00 app[web.1]: sh: 1: parcel: not found
2020-09-03T11:50:34.014930+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:34.015162+00:00 app[web.1]: npm ERR! syscall spawn
2020-09-03T11:50:34.015163+00:00 app[web.1]: npm ERR! file sh
2020-09-03T11:50:34.015295+00:00 app[web.1]: npm ERR! errno ENOENT
2020-09-03T11:50:34.017581+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 parcel:serve: `parcel serve index.html --no-source-maps`
2020-09-03T11:50:34.017582+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-09-03T11:50:34.017742+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:34.017743+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 parcel:serve script.
2020-09-03T11:50:34.017883+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:34.025870+00:00 app[web.1]: 
2020-09-03T11:50:34.025871+00:00 app[web.1]: > phaser3-multiplayer-example-with-geckos.io@1.0.0 server:serve /app
2020-09-03T11:50:34.025872+00:00 app[web.1]: > nodemon --delay 500ms server/server.js
2020-09-03T11:50:34.025872+00:00 app[web.1]: 
2020-09-03T11:50:34.027189+00:00 app[web.1]: 
2020-09-03T11:50:34.027320+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:34.027321+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_34_018Z-debug.log
2020-09-03T11:50:34.031929+00:00 app[web.1]: sh: 1: nodemon: not found
2020-09-03T11:50:34.040640+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:34.040640+00:00 app[web.1]: npm ERR! syscall spawn
2020-09-03T11:50:34.040640+00:00 app[web.1]: npm ERR! file sh
2020-09-03T11:50:34.040641+00:00 app[web.1]: npm ERR! errno ENOENT
2020-09-03T11:50:34.040641+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 server:serve: `nodemon --delay 500ms server/server.js`
2020-09-03T11:50:34.040642+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-09-03T11:50:34.040642+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:34.040643+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 server:serve script.
2020-09-03T11:50:34.040643+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:34.047650+00:00 app[web.1]: 
2020-09-03T11:50:34.047753+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:34.047849+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_34_041Z-debug.log
2020-09-03T11:50:34.053474+00:00 app[web.1]: ERROR: "parcel:serve" exited with 1.
2020-09-03T11:50:34.060590+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:34.060794+00:00 app[web.1]: npm ERR! errno 1
2020-09-03T11:50:34.063216+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 dev: `npm-run-all --parallel parcel:serve server:serve`
2020-09-03T11:50:34.063321+00:00 app[web.1]: npm ERR! Exit status 1
2020-09-03T11:50:34.063438+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:34.063525+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 dev script.
2020-09-03T11:50:34.063597+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:34.070140+00:00 app[web.1]: 
2020-09-03T11:50:34.070279+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:34.070349+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_34_064Z-debug.log
2020-09-03T11:50:34.077867+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-09-03T11:50:34.078106+00:00 app[web.1]: npm ERR! errno 1
2020-09-03T11:50:34.081862+00:00 app[web.1]: npm ERR! phaser3-multiplayer-example-with-geckos.io@1.0.0 start: `npm run dev`
2020-09-03T11:50:34.082019+00:00 app[web.1]: npm ERR! Exit status 1
2020-09-03T11:50:34.082220+00:00 app[web.1]: npm ERR!
2020-09-03T11:50:34.082362+00:00 app[web.1]: npm ERR! Failed at the phaser3-multiplayer-example-with-geckos.io@1.0.0 start script.
2020-09-03T11:50:34.082456+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-03T11:50:34.092645+00:00 app[web.1]: 
2020-09-03T11:50:34.092775+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-09-03T11:50:34.092877+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-09-03T11_50_34_086Z-debug.log
2020-09-03T11:50:34.139218+00:00 heroku[web.1]: Process exited with status 1
2020-09-03T11:50:34.181211+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-03T11:50:34.782730+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=young-shelf-51270.herokuapp.com request_id=b2a4796a-e0d9-46ba-a5dd-f1c8860f843a fwd="49.185.11.69" dyno= connect= service= status=503 bytes= protocol=https
2020-09-03T11:50:39.000000+00:00 app[api]: Build succeeded

It was a similar solution for parcel: not found and nodemon: not found.

Then there was a memory limit causing it to crash. I found this solution for that, specifically this command:

heroku config:set NODE_OPTIONS="--max_old_space_size=2560" -a [app_name]"

So that’s swap space sorted, but it is still using more RAM than allocated:

2020-09-03T14:16:37.791525+00:00 heroku[web.1]: Process running mem=703M(137.4%)
2020-09-03T14:16:37.797196+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)

but now I’m now getting a black screen from the [client address](http://2020-09-03T14:16:37.791525+00:00 heroku[web.1]: Process running mem=703M(137.4%) 2020-09-03T14:16:37.797196+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)) so that is some progress at least.

It looks like the free limit for Heroku is 512MB. The Heroku support section says the server will restart if it reaches double the quota at 1024MB but doesn’t say whether it would impede functionality prior to that.

Hi @Jimage

I’m sorry, I did not see your message earlier. You can address issues with geckos.io directly to me (@yannick)

Geckos needs open UDP ports. That’s what makes it so fast. On services like Heroku it not possible to open UDP ports.

See: https://github.com/geckosio/geckos.io/issues/13

Right, so it’s a waste of time trying to set it up on either of these services. Guess I’ll have to find a good web host to self-host it. Do you have any recommendations for NodeJS hosting that wouldn’t be too expensive?

I got the sockets.io tutorial running on NearlyFreeSpeech but the latency was ridiculous compared with Heroku and Glitch. Tried to test geckos on it but some of the dependencies give 404 errors on the FreeBSD server. Haven’t checked if it can even forward UDP sockets either now that I think about it.

Does the memory problem seem like a normal thing? Doesn’t seem to use that much memory locally from what I can tell.

I tried to hack it up to remove the phaser-on-nodejs and work more like the authoritative server sockets.io example in case the phaser-on-nodejs library was contributing to this, since from what I understand it runs a whole browser instance in the background. Got some basic text communication going but the JavaScript is a bit more advanced when it comes to the actual game logic so I couldn’t quite get it fully functional.

If I can get it working as-is, it looks like a good enough base to build some of the more basic ideas I have in mind without having to deal too much with the low-level stuff.

I recommend Ubuntu 18.04 on DigitalOcean or AWS Lightsail.

This example uses parcel to bundle. Even though the game does not need a lot of memory, the bundler needs a lot of it. I recommend using webpack instead of parcel or to pre-bundle your game before uploading it to your server.

No, it does not run a whole browser. It’s not like puppeteer.


If you want to test geckos.io on your server, I recommend using the simple-chat-app-example instead.

Do not forget to add the default Ice Servers for testing it on your server.