I want to build an Android app that streams data from wireless sensors (about 3 kb/s) to my server.

To wake up the phone it turned out I cannot easily use a socket from my server, but need a GCM push notification. However, if Im implementing all the GCM stuff just to start streaming, it could be easier to use GCM for the datastream too, instead of my own websocket implementation.

The docs say a packet can be max 4 kb, and that should be enough if the device can reliable transmit them once per second. But since GCM wasnt designed for such fast interval and bandwiths, does anyone have experience if it would be feasible and reliable, or would it be better to open a direct connection to my server instead?

有帮助吗?

解决方案

I would go with a direct connection to your own server, mainly because as you say, the GCM service wasn't really designed for this and Google hold the right to throttle the connection and delay the GCM notifications if they think you are using too much bandwidth. I've experienced this myself when conducting stress tests - the notifications start slowing down and eventually the gmail accounts that the devices where using were banned.

The general pattern for GCM should be something similar to:

  1. Something happens on the server that the devices need to know about.

  2. A GCM notification is sent to the device with a small payload, say CommandNumber = 1 for example.

  3. The device listens to the notification, and because the CommandNumber == 1 it responds in a certain way, which could be opening a socket to your server in this case.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top