Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 495
Marcos Bergamo Avatar asked Dec 01 '14 21:12

Marcos Bergamo


3 Answers

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.

like image 129
Jeff Deskins Avatar answered Oct 07 '22 08:10

Jeff Deskins


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.

like image 42
Marcos Bergamo Avatar answered Oct 07 '22 09:10

Marcos Bergamo


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
like image 2
Kyle Finley Avatar answered Oct 07 '22 08:10

Kyle Finley