Launch Websocket on GAE

I am trying to adapt my application using websocket to run in GAE, but reading Docs, I cannot find an acceptable solution to this problem.

Using a really simple app: https://github.com/marcosbergamo/gae-nodejs-websocket

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

Follow the images about the request;

enter image description here

+6
source share
4 answers

After many hours of studying and testing, a friend at Google shows me one solution to this problem! Thanks Thiago Avancini!

Well, the solution is:

The first step is to use managed vms. (The repo uses it.) But the goal is to switch control from Google to the user. When you do this, the next step is to create a static IP address for your application. In my case, I use port 3000 to service my Websocket, feel free to change. On my app.yaml, I also enabled this port as follows:

network: forwarded_ports: ["3000"] 

Do not forget to include this port in the proxy in "network → default → firewall".

If you are deploying the application through gcloud, you need to re-enable user management and a static IP address in your application.

I will send this repo to GoogleCloudPlatform, this will be a sample for using websockets in AppEngine.

+2
source

To use web ports, you must use a managed VM with a custom runtime.

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

Once this is started, you will need to access this server directly using ip or cname. You cannot go through the appspot.com domain.

+4
source

Unable to connect incoming sockets:

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

You cannot create a socket to listen to; You can create outgoing outlets.

0
source

Update: February 4, 2019

Google Announces WebSockets Support for Flexible App Engine

WebSockets is available for your App Engine agile application without special configuration. Check out our documentation to learn more: Python | Java | Nodes .

You must add to your app.yaml

 network: session_affinity: true 
0
source

Source: https://habr.com/ru/post/978963/


All Articles