I am running node-red on Android (6.0) under Termux, started on boot by Tasker. All is working well apart from the fact that if not charging then if I leave the device for a while then it seems that certain parts of node-red start dozing off.
For example, if I have an Inject node set to fire every minute then it only fires every five or ten minutes. Similarly if I have a setInterval()
loop running in a function node which should trigger every minute and send a message then it also slows down. Similarly node-red-contrib-cron-plus does not fire reliably.
I am also running mosquitto on the device and, interestingly, if I publish (from another device) to a topic every minute and subscribe to that in node-red then that is seen and actioned by node-red as it should, even though the other nodes are still going slow.
I have set Termux to not use Battery Optimisation and automatic Battery Saver is disabled. Any suggestions as to what I can do?
When I was a lad and did Android apps, if you wanted to keep something going - you'd write a server bit and a front-end GUI bit and the OS wouldn't put the server to sleep (unless really pushed)
Since Node-RED running in Termux won't have been written this way - the OS will just treat it as an ordinary app and try and put it to sleep if its GUI is not actively being used
Things might have changed since 2010 of course
Is that consistent with the fact that it continues to work correctly when on charge (at least it does for a while, I need to leave it all day to make sure it continues as it should).
Also is your suggestion consistent with the fact that it continues to respond correctly to mqtt inputs (even when not charging).
As it is it means that node-red is not really usable on Android unless it is on charge. At least on my phone anyway.
Blast, I have two long term things to test now. I am using node-red to interface with my caravan's heating system, which is a Sonoff TH10 with the tasmotta s/w. The Sonoff sends an MQTT status every 10 seconds so I could do DIY scheduling using that signal to drive the flows that I want to drive with the cron-plus node. So I need to check over an extended period whether node-red continues to respond to MQTT when not on charge. However another option is to keep it on charge all the time so I also need to check whether cron-plus and inject nodes continue to function normally over an extended period when it is on charge. Don't know which to do first.
[Edit] I am also using Tasker and Termux to run mosquitto and ssh server on boot and they keep working all the time as far as I can determine.
Like I say - my knowledge is 9 years old but a native app used to be basically split into two parts - a server that runs all the time and a GUI that was considered expendable
I gave up on finding a solution to the underlying problem (setInterval and setTimeout going slow) and replaced all asynchronous nodes with non-asynchronous nodes (scheduler, rate limit etc) using a trigger from MQTT subscribed to a status message from an attached Sonoff device (every ten seconds) to drive the replacement nodes.