I have an app that supports a two way connection between a "master" device and multiple "remotes" using the Google App Engine Channel API. To conserve data consumption, the "master" only sends it's data to the remote devices who have been noted in a datastore entity. It Looks like this:
{"ag5zfnBhbmRvcmEtaG9tZXIVCxINU29ja2V0U2Vzc2lvbhjZswEMremote1": "AHRlWrqfFk1Od_9FMObXMnbQRV0NPlAD41aRaYCZ8-dzpAV4aZI-6XjGqhlRBbGL8P4slwTUTw4mI2Mb8VgqWSnMbNyO7ewRHCwVnqCvY9vA-XS4vyESFlNS3nRbdeEjuCXEXMSMxiguixfjPDF5fiseQkXm2SOp2c0YD6onfM7PpN6gGDicH5A", "ag5zfnBhbmRvcmEtaG9tZXIVCxINU29ja2V0U2Vzc2lvbhjZswEMremote0": "AHRlWrr5tXCamZ5fN4z8LUM1Wj_60GFNYS7kOEokAM_QeAAL7nlYo5EDuYeEpz_kepwK-k1kQ543jDeTLmUXws9n_3L-ty1rsYUN3SIILfaf4_4UXDVujj6tWed2nmXvbZ8ScX7dOilJBjc_xdvIu6NRDhqe-Pt1oinRXcsAc_NpDFQEOs_5bH8"}
It is simply a key that matches channel keys to tokens. The entity then can also determine which remotes are online and which can be reused and when they expire. They are added using the channel presence inbound handler and removed from the entity by its disconnect handler as well. However, because these devices may disconnect at anytime it isn't practical to recreate a channel token for each remote. Thus when connecting to the server, the server checks if any old tokens that haven't expired are not in use and instructs the remote device to use it by returning the old channel token via the key to token lookup in the datastore entity.
While the channel receives data as it should, the channel presence does not receive the request that it is connected. More interestingly, it never gets a ping when the remote is disconnected either which is most likely due to the unbeforeload issue in safari for the iPhone (the remote platform). However in the dev-server it works perfectly. Is this a bug or is it possible that reusing tokens in this manner is not reliable.
NOTE While i could just update the datastore of the presence of the new remotes upon determining if the remote should use an old or new token i'd rather use the channel presence as a cleaner method in verifying that the socket did in fact connect with the client.
EDIT Furthermore i am finding that if a remote token has been inactive for about 4-8 minutes before another remote tries to use it, this phenomenon does not occur.
EDIT2 In addition, I have noticed that when using an iPhone the channel almost always triggers its onerror handler a few minutes after a reliable connection regardless of using a new or old token. However, on a laptop this does not occur.