Search code examples
google-app-enginechannel-api

Channel presence urls not getting called when user reloads the page


I am on SDK 1.6.5, Python 2.5

When I start my dev server and visit my channel test page at 127.0.0.1 everything works fine - token is generated and passed to front end, socket opens, client connected ping is received, my app sends a message to the client, it is received.

If I reload the page:
- no disconnect ping shows up in my logs (It should?)
- new token is generated (OK)
- front end js logs a socket opened with new token (OK)
- no client connected ping received
- ...my server-side code is now unaware that this socket is open and doesn't know how to send messages to the client

Am I misunderstanding the proper flow here?

If I shift+reload the page it's the same. I have to restart the dev server in order to get everything to work again.

Using djangoappengine:

inbound_services:
- warmup
- channel_presence

handlers:
- url: /_ah/channel/.*
  script: djangoappengine/main/main.py

Solution

  • This is, more or less, expected, if you're using the same client id. The basic reason is this: a given client id, app id and version map to a specific XMPP endpoint. The XMPP frontends don't want to barrage clients with disconnect/connect notifications if clients go offline for a short period of time (say, a couple of seconds). A page refresh is basically like losing and re-negotiating a network connection, so this case is treated like a temporarily dropped connection, and no disconnect/connect is sent.

    If you really need to get the disconnect on page refresh, you could work around this by using a different client id on the call to create_channel on every page request.