Real-time Gaming with Node.js + WebSocket tutorial?

867 views
Skip to first unread message

Mattias Johansson

unread,
Apr 24, 2016, 6:53:47 AM4/24/16
to gce-discussion
I'm a front-end developer that want to use websocket+node.js for a game in the browser.
What I'm asking for is a great tutorial on how to get that working in the Google Cloud or any other help for that matter. 

What I found is this:
https://cloud.google.com/solutions/real-time-gaming-with-node-js-websocket
But I'm not that familiar with the server end and is all new to the Google platform so it doesn't help me a lot. 

I have a simple socket example working as long as it's in my local environment but when I deploy it I get lot's of strange errors in the console.

You can find it here

There error in the console log says:

WebSocket connection to 'ws://socket-1281.appspot.com/socket.io/?EIO=3&transport=websocket&sid=BXTZAZbQVQYA1TBLAAAA' failed: Error during WebSocket handshake: Unexpected response code: 400
Failed to load resource: the server responded with a status of 400 (Bad Request)

So does anyone know how to solve this or where to find help?

Here's the source

Kamran (Google Cloud Support)

unread,
Apr 24, 2016, 4:05:20 PM4/24/16
to gce-dis...@googlegroups.com

Hello Mattias,

Is this still an issue? as I can see that your application is up & running at http://socket-1281.appspot.com/

Sincerely,

Mattias Johansson

unread,
Apr 25, 2016, 2:45:46 AM4/25/16
to gce-discussion
Yes!
If you look in the log it's still full of errors.

Nicholas (Google Cloud Support)

unread,
May 2, 2016, 12:26:05 PM5/2/16
to gce-discussion
According to this StackOverflow post, you cannot use sockets with the appspot domain. You would need to use App Engine Flexible environment with a custom runtime. Then, you could specify different ports to expose from your Docker container and your contained application to use with the ws and wss protocols.

In reviewing the source code you provided, you're using the nodejs runtime instead of custom and no custom ports are used either. Also, your project is no longer accessible via appspot. I am only getting 404s. Have you recently opted to shut down your application?


On Sunday, April 24, 2016 at 6:53:47 AM UTC-4, Mattias Johansson wrote:

Mattias Johansson

unread,
May 4, 2016, 8:12:54 AM5/4/16
to gce-discussion
Thank you!
I also found this: 
, which doesn't work perfectly but is a good help. I'm working on a new solution and cleaned up a lot of broaken stuff o my Google Cloud.

Nicholas (Google Cloud Support)

unread,
May 4, 2016, 10:41:58 AM5/4/16
to gce-discussion
Thank you for posting an example application here. I'm happy to hear you got a WebSocket server up and running. For the purposes of the community, Introducing WebSockets is a helpful article about WebSockets in HTML 5 and links to a few NodeJS WebSocket libraries including:
Did the example you mentioned in your previous post work for you as is? If not, what modifications did you have to make for it to work?

On Sunday, April 24, 2016 at 6:53:47 AM UTC-4, Mattias Johansson wrote:

Mattias Johansson

unread,
May 4, 2016, 10:50:26 AM5/4/16
to gce-discussion
I'm not there yet. I bussy working on other stuff :/
But almoste. I will create the tutorial I'm looking for once I've got it working.
Reply all
Reply to author
Forward
0 new messages