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?
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- __call__() missing 1 required positional argument:
- Upload file to Google Cloud Storage using AngularJ
- Where is the best place to put one-time and every-
- facebook “could not retrieve data from URL”
相关文章
- Is there a size limit for HTTP response headers on
- appcfg.py command not found
- Google app engine datastore string encoding proble
- Angular route not working when used with Google Ap
- Doctrine not finding data on Google App Engine?
- Using OkHttp client via OKClient on Google App Eng
- Google appEngine: 404 when accessing /_ah/api [dup
-
Google App Engine Error:
INVALID_ARGUMENT
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
Google AppEngine has a new feature Channel API, with that you have a possibility to build a good realtime application.
Another solution is to use a third part comet server like mochiweb or twisted with a iframe pattern.
Client1, waiting a event:
Client2, sending a message:
To use mochiweb with comet pattern, Richard Jones has written a good topic (on google: Richard Jones A Million-user Comet Application).
We've tried implementing a Comet-like long-polling solution on App Engine, with mixed results.
The problem I'm seeing is that requests following a long-polling one, are getting serialize (synchronized) behind the long-polling request. I can look at a trace in Chrome and see a timeline like this:
I've used wireshark and Chrome/timeline to confirm that I AM sending the modification request to the server on a distinct TCP connection from the long-polling one. So this snychronization must be happing on the App Engine production server. Google doesn't document this detail of the server behavior, as far as I know.
I think waiting for the channel API is the best hope we have of getting good real-time behavior from App Engine.