How can I run a WebSocket server on top of GAE?

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.


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.


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:

  • http://googleappengine.blogspot.com/2010/05/app-engine-at-google-io-2010.html
  • http://bitshaq.com/2010/09/01/sneak-peak-gae-channel-api/

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