Marcos Bergamo
Marcos Bergamo

Reputation: 1123

Run Websocket on GAE

I'm trying adapt my app using websocket to run on GAE, but reading the Docs, I'm not find a pretty solution to this problem.

Using a really simple application like that: https://github.com/marcosbergamo/gae-nodejs-websocket

This is my sample demo trying use. But I'm receive this error when I try to connect to my websocket;

Follow the image about the request;

enter image description here

Upvotes: 7

Views: 4848

Answers (4)

Kyle Finley
Kyle Finley

Reputation: 11992

Update: February 4, 2019

Google Announced WebSockets support for the App Engine Flexible Environment

WebSockets is available to your App Engine Flexible Environment application with no special setup. Take a look at our documentation to learn more: Python | Java | Nodejs.

You must add to your app.yaml

network:
  session_affinity: true

Upvotes: 2

Marcos Bergamo
Marcos Bergamo

Reputation: 1123

Later a lot of hours study and tests, a friend in Google show me one solution for this problem! Thanks Thiago Avancini!

Well, the solution is:

The first step is using the managed-vms. (The repo use it.) But the goal is switch the managing from Google to User. When you do this, the next step is create an static IP for your application. On my case I using the port 3000 to serving my Websocket, feel free to change. On my app.yaml I enable this port too like this:

network:
  forwarded_ports: ["3000"]

Remember to enable this port on the proxy in "network>>default>>firewall".

If you deploy the application via gcloud, you need enable again on your application the user management and the static IP.

I'll send to GoogleCloudPlatform this repo for will be a sample for using websockets on AppEngine.

Upvotes: 2

Jeff Deskins
Jeff Deskins

Reputation: 1660

In order to use websockets, you must use the Google Managed VM with custom runtime.

https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes

Once that is running, you will need to access that server directly by ip or cname. You cannot go through the appspot.com domain.

Upvotes: 4

Paul Collingwood
Paul Collingwood

Reputation: 9116

Can't have incoming socket connections:

https://cloud.google.com/appengine/docs/python/sockets/#limitations-and-restrictions

You cannot create a listen socket; you can only create outbound sockets.

Upvotes: 0

Related Questions