Kamil Janowski
Kamil Janowski

Reputation: 2025

GAE Push notifications

I'm still at the level of experimenting with GAE and I was wondering if it's possible for GAE to somehow keep the socket open for indefinite period of time, or perhaps generate some kind of push messages. I want to write a desktop application that will communicate with the backend running on GAE and every once in a while display some notifications if some get generated by the backend, but I don't quite like the idea of polling the server every few seconds. Any ideas?

Upvotes: 0

Views: 82

Answers (1)

Peter Knego
Peter Knego

Reputation: 80340

A few notes on existing APIs and why they would not work for a native desktop app:

  1. Channels API is a javascript-based browser-only solution, so it would not work for a native desktop app.
  2. XMPP API allows your GAE app to function as a XMPP client: sending and receiving messages. It does not act as a server and has no facilities for external clients to connect to it (requires external XMPP server to do so).
  3. Sockets API is outbound-only. It does not allow you to open listening sockets needed for long-running server-to-client push.
  4. Outbound Sockets, where server connects to client: most clients are behind NAT, so even if tempting, server-to-client socket connections can not practically be established. Even if you are willing to delve into the world of STUN, GAE limits number of threads needed to service sockets (select-based NIO is not available).

Running server-to-client async push is not possible on normal GAE instances. There are however two practical approaches:

  1. Use external services: depending on number of connections, this might be the cheapest (in terms of time & cost) solution. See Pusher, PubNub, etc..
  2. Use Managed VMs. They run the full JVM (or Python, Go, Node.js), so do not have above limitations. You can run any existing pub/sub server.

Upvotes: 1

Related Questions