views:

164

answers:

2

I need to make application that needs to poll server often, but GAE has limitations on requests, so making a lot of requests could be very costly. Is it possible to use long polling and make requests wait for the maxium 30 seconds for changes?

+1  A: 

I don't think long polling is possible. The default request timeout for google appengine is 30 seconds. In long polling if the message takes more than 30 secs to generate, then it will fail. You are probably better off using short polling.

Another approach is to "simulate" long polling withing the 30 sec limit. To do this if a message does not arrive within, say 20 sec, the server can send a "token" message instead of a normal message, requiring the client to consume it and connect again.

There seems to be feature request (and its accepted) on google appengine for long polling

naikus
+2  A: 

Google AppEngine has a new feature Channel API, with that you have a possibility to build a good realtime application. http://goo.gl/QNPc

Another solution is to use a third part comet server like mochiweb or twisted with a iframe pattern.

Client1, waiting a event:

client1 --Iframe Pattern--> Erlang/Mochiweb(HttpLongPolling):

Client2, sending a message:

client2 --XhrIo--> AppEngine --UrlFetch--> Erlang/Mochiweb

To use mochiweb with comet pattern, Richard Jones has written a good topic (on google: Richard Jones A Million-user Comet Application).

sahid
Channel API isn't public yet. Here are two more alternative services to check out:http://beaconpush.comhttp://pubnub.com
Ikai Lan