I have successfully setup NodeRED on an AWS EC2 instance and use MQTT as a means to communicate from/to my IoT devices (ESP8266/ESP32 at the moment).
I'm running a compiled version of Tasmota that has AWS IoT enabled.
What's strange is the MQTT nodes in my flow disconnect every few days (no pattern as far as I can tell). To reconnect I edit one of the nodes (same config for all MQTT nodes), edit the MQTT broker (simply 'edit' followed by 'update' without any changes) and deploy the flow. Nodes reconnect and everything works fine.
My Internet connection shouldn't come into play here as the NodeRED instance/app runs on AWS EC2 and connects to AWS IoT Core so this should be within the AWS Cloud environment as far as I can understand. Even if EC2 and the IoT Core were on different regions it's still AWS and any latency shouldn't influence this, right?
Does NodeRED have the ability to automatically reconnect on dropping of a connection?
What's the easiest way to diagnose this/what log files could I use to even start investigating?
Hmm. I haven't touched this instance in months. I'd hope that these don't just reboot by itself. Where would I find the NodeRED logs for a standard install? Maybe there's something to be found...
Followed the AWS instructions. All ok except the last one where the pm2 startup asks you to edit a startup script. What file am I looking for and where would that be located?
PM2 is trying to tell you to run that command for PM2 to be set as a systemd script and start up automatically. After that is done, you'll need to start Node-RED using PM2 and then it should be managed by it.
Thanks. Well, that's almost embarrassing to have missed that
Node-RED comes up automatically.
Where does Node-RED log to by default given it runs as a service? I'm not a Unix expert so struggling a bit here. Had a look at /node-red/settings.js and the section logging states only console logging is supported. Given I just moved away from the console what happens to logging?
If you're running it using PM2, the logs will be handled by it and by default placed under $HOME/.pm2. It will log what would otherwise have been displayed on the console. So I assume the logs will be under /home/ubuntu/.pm2 in your case.
Note that PM2 can write errors to a separate file if configure so. If I remember correctly that is the default.