开发者

App engine Channel API returns no messages

Problem description: channel messages no returned to ajax script. Initially, messages are delivered to clietn side, but the problem appears when I set larger timeout in js:

goog.appengine.Socket.POLLING_TIMEOUT_MS = 5000; //poll every 5 seconds

I've added a very basic Python code to test if Channel API works in my Google App Engine app.

index:
token = channel.create_channel(CHANNEL_NAME)
channel.send_message(CHANNEL_NAME, message)
#token is passed to template

additional_view:
#is another view, trigger manually from browser after index
from django.utils import simplejson
channel.send_message(CHANNEL_NAME, simplejson.dumps(data))

At client side I have a regular js with onMessage code.

The problem is that no messages are returned to client-side requests. They all come empty to polling ajax (as seen in Firebug). In application log I can see that channel is created:

"Creating channel token channel-2382918168-broadcast with client id broadcast" and later message is sent but with a comment:

in between come these requests:

INFO     2011-08-03 14:33:32,000 dev_appserver.py:4248] "POST /_ah/channel/connected/ HTTP/1.1" 404 -
INFO     2011-08-03 14:33:33,780 dev_appserver.py:4248] "POST /_a开发者_Go百科h/channel/disconnected/ HTTP/1.1" 404 -

** ....message text...to channel with key (broadcast): no clients connected***

How does channel/message function at deeper level? Are messages lost if no clients are connected or they are retrived by newly connect clients? If for some reason I create a channel with the same name, would it distroy undelivered messages it has inside?


Stay away from setting the POLLING_TIMEOUT_MS higher than 1.5 sec, the dev_appserver will assume you have disconnected.

It does not work via polling in production, so you do not have to worry about the timeout really.

Edit: just saw Robert's comment; personally I have even had issues if I set the polling to 3sec in Chrome/Safari/Firefox. I now just have ?disable_channel=true query strings on my apps so that I can run them without setting my laptop on fire with the CPU usage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜