Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT as logging Option #615

Closed
ThoMagnum opened this issue Jan 29, 2018 · 2 comments
Closed

MQTT as logging Option #615

ThoMagnum opened this issue Jan 29, 2018 · 2 comments

Comments

@ThoMagnum
Copy link

Hello,

I found this awsome piece of Software and are very happy with it, but I am looking for an option to directly track to an MQTT Server, so that I can use the GPS data for several scenarios in my home automation solution.
Would it possible to log, beside the other options, directly to an MQTT Server?
To understand what I mean, it is a functionality as given in OwnTracks Client.
I appreciate your answer.

Best regards, Thomas

@mendhak
Copy link
Owner

mendhak commented Jan 30, 2018

I did indeed have a look at MQTT when this issue was raised. I've added some notes there.

Since then I've done a bit more trying. That issue is closed so I'll add extra info here.

That Android library requires a wakelock permission and in turn I would need to ask users for this permission. That is extremely undesirable. The last time I tried it, the library would crash if I didn't explicitly ask for wakelock permission. But this wakelock is somewhat necessary.

MQTT requires a TCP session between the client and server, so that expense of opening a new session is taken care of at the beginning; then there are keep-alive pings which the client must send within a specific timeout and if this doesn't happen, the Last Will is sent. This will require, in the GPSLogger app, an extra AlarmManager which must wake the phone up periodically and ping the server. This ping will be independent of the logging interval, so I can't piggyback off that.

Another option was to send MQTT the expensive way - each logging interval open a connection, sends message, disconnects. Further, because I want to follow Android's doze mode implementation, the messages to the server will bunch up and there can't be any expectation of near-realtime logging and potential surprise when users notice frequent disconnect messages causing topic client notifications. Also worth adding, with each new Android release, client background activities are more and more restricted, in order to save battery life.

So option could be, I fork the Paho Android library, and remove the wakelock bits, only use the library to single-messages. But that forking does mean a high maintenance overhead, lack of updates.

I could write my own library - which only sends MQTT messages and nothing else - but at that point , this is an MQTT client which is not really a proper MQTT client and breaking some of the benefits that MQTT is supposed to provide, however I don't fully believe that MQTT works in the Android recommended lifecycle where the OS can kill activities and services at any time.

Just for reference I found these as extra useful reading

http://dalelane.co.uk/blog/?p=1599
https://stackoverflow.com/questions/10065624/how-to-send-ping-using-eclipse-paho-mqtt-client

eclipse/paho.mqtt.android#104
eclipse/paho.mqtt.android#195

@mendhak
Copy link
Owner

mendhak commented Apr 7, 2023

Closing this one - sadly the MQTT library hasn't seen an update in years (like GPSLogger lol) and I don't have enough bandwidth to do a custom library just for this either.

@mendhak mendhak closed this as completed Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants