Hi!

Do you have enough power for the device so it can run 24/7 without
sleeping? i.e. an external battery or power source?

If not, have a look at this example using MQTT. It worked for me but I
am not sure about the licensing of the wmqtt.jar.

http://dalelane.co.uk/blog/?p=1599&cpage=1

It should be possible to adapt this strategy to XMPP.

It boils down to this:

- create a service (make it sticky)
- Create a tcp connection (to a server)
- Register Broadcast Receiver for network connectivity changes and alarm
after 20 minutes (or more/less depending on NAT timeouts of your network
provider)
- Schedule an alarm (to send keepalive packet)
- Go to sleep
- When alarm is triggered: send ping (sleep again)
- When network is lost: cleanup (sleep again)
- When message comes in: handle message (sleep again)
- When connectivity is restored: reconnect (sleep again)

The problem with the paho and the fusecore mqtt-client implementation
is, that they do not allow sending a ping request "manually". So you
have to either patch them or send a bigger publish packet.

Regards,
Dirk


> danaimset <mailto:[email protected]>
> 20. September 2013 08:32
> Hi all!
>
> I'm working with one very wide project and we need to support 24/7
> connection with device. 
> This project is for custom ROM and we will not have Google apps installed.
> We are thinking about performance. Maybe someone could help us with
> the following questions:
> How many TCP connections Google Services keep in android ? And what is
> the best practices.
>
> We need to have realtime support for all our components that will be
> controlled through the web admin.
> So we'll have to implement our own Cloud Messaging. We concentrated on
> XMPP solution that we may know.
>
> Maybe someone could suggest the best approach.
>
> Thank you,
> Dan.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to