32
votes

How can I run a WebSocket server on top of Google App Engine? Is it possible? Will it be possible?

10
From 2010 to 2013 lots of things have changed. See Channel developers.google.com/appengine/docs/python/channel/?csw=1 - Josep Valls
@JosepValls, Is that solution built on top of the WebSocket standard or is it a Google-specific technology? - Pacerier

10 Answers

26
votes

Is it possible?

No.

You can't right now because GAE doesn't allow generic inbound socket connections. Each request is also limited to 30 seconds but this could easily be worked around with automatic reconnection and session tracking.

Will it be possible?

Probably.

Google has been one of the biggest (main) promoters of the WebSockets standard. I would be surprised if they don't push support for it into GAE at some point in the future. Note that the WebSockets draft standard is still in flux so Google might be hesitant to add support before the standard is more solid.

Here is the bug for WebSockets support on GAE: http://code.google.com/p/googleappengine/issues/detail?id=2535

Note that a google employee indicates it's not on the roadmap but that they know it would be useful. That's about as positive an answer as you get from google about features that have not been announced. I recommend adding your voice to that bug in favor of WebSocket support. It can't hurt.

Also, depending on your application, you may consider the Channel API which will likely have GAE support soon:

EDIT (2015): the Channels API is available now (it has been for a while).

19
votes

All of these answers are out of date.

The Channel API has been deprecated. Google strongly recommends you use Firebase.

It is also worth noting, that Google has now released the flexible environment.

With the flexible environment, you could easily allow socket connections, or use Python 3.

10
votes

It's officially supported now.

See https://cloud.google.com/appengine/docs/python/channel/

EDIT: the Channel API is supported, not WebSockets. The Channel API is built on WebSockets, but it doesn't give you direct access to the WebSocket. I suppose it's good enough for typical Web apps.

4
votes

As of January 9, 2019 it is officially in Beta now - but only for App Engine flexible. For example, see the Python documentation. According to the issue tracker, it will work with any language, though.

2
votes

You can't.

GAE limits HTTP requests to 30 seconds, WebSockets expect to have connection open for a long time.

Will it be possible? Only Google knows this.

2
votes

A couple people have gotten websockets working with GAE with the help of another server... checkout http://code.google.com/p/typhoonae/wiki/WebSockets

1
votes

There's also this: https://cloud.google.com/appengine/docs/go/sockets/ It's experimental and very low level though.

1
votes

Google App Engine has recently launched support for Websockets on App Engine Flexible Environment. You can take a look at their blog post.

https://cloud.google.com/blog/products/application-development/introducing-websockets-support-for-app-engine-flexible-environment

1
votes

June 2019

Websocket support for GAE is now supported under SLA for Flex.

Hi everyone, I'm happy to announce that Websockets support 
for Flex is now Generally Available! We've made no changes since Beta 
but Websockets traffic is now subject to our SLA. 

We've also published documentation for this feature for all App Engine Flex languages.

See https://issuetracker.google.com/issues/35886348#comment285

0
votes

Hope helps, but seems to be supported now. 2021 [https://cloud.google.com/appengine/docs/flexible/java/using-websockets-and-session-affinity][1]