Gustavo Mendonça
Gustavo Mendonça

Reputation: 2091

Google App Engine using sockets with NodeJs

I'm using Google App Engine to run a node js application and it works. The issue is that I want to run another node js application which is actually a websocket and searching on the internet and the docs, I found that they support now sockets (before they didn't)!

The only thing is that the node js documentation is missing or they still do not support sockets only for node js, but I can't find the answer for that.. Maybe someone have a work around for that.

Please, do not suggest using Google Compute Engine to run my websocket server, I know that works.

Upvotes: 3

Views: 896

Answers (2)

luky
luky

Reputation: 212

This app.yaml configuration worked for me:

runtime: nodejs env: flex manual_scaling: instances: 1 network: session_affinity: true

And I enabled the firewall rules by this command:

gcloud compute firewall-rules create default-allow-websockets --allow tcp:65080 --target-tags websocket --description "Allow websocket traffic on port 65080"

Upvotes: 0

Ryan Joseph
Ryan Joseph

Reputation: 350

If you’re using Google App Engine Flexible, websocket are available in beta.

I used that example and deployed it on App Engine Flex, and it works

Since not all clients support websockets, a common workaround is to use Socket.IO

If you will be using Socket.IO you will need to change the session affinity in your app.yaml like so

network:
  session_affinity: true

You will find more information about that here

Upvotes: 4

Related Questions