A Node.JS Websocket Server on Google App Engine

HuanTing Chen
Google Cloud - Community
2 min readMay 10, 2017

Recently I implement a websocket server to demo some iOS feature. That server is originally run perfectly on my local side. After some testing, I decide to move the websocket server to google cloud platform to get public ip for demo purpose.

This is my first time using App engine and it really take me a lot of time.

Here are some simple steps for deploy a web socket to GAE.

First, register google cloud platform, now it provide 300 free trail for testing its’ cloud services.

After registry, Clicking App Engine and run the official quick start tutorial step by step.

OK. now we have ability to deploy node.js projects to App Engine.

Then, clone a websocket sample from:

https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/websockets

This is an example from google. It shows how to implement websocket on app engine.

So, we clone the project in gcloud console and deploy and everything will be fine?

NO. we need some modification.

First, modify app.yaml:

#vm: true

env: flex

And Please pay attention to the end of this file:

This part is very important.

And then, enable the port 65080 for your firewall via the command listed in README

After this, just deploy to App Engine and everything will really be fine this time.

After deploy, we will get an URL like:

https://{project name}.appspot.com

Replace https to http since websocket on App Engine is not support secure mode now.

Then, launch the new url started with http:// and try the websocket now!

Note: App Engine preview mode is not work for websocket in my test.

--

--