In short, thats not how you would make a connection with mariadb in Node-RED.
Looks like its just a cut/paste from some computer code vs Node-RED.
You will need to first ensure you have a shell license installed on your EPIC. (Its a free option, but if you are not comfortable with a good level of Linux command line experience, you might want to rethink your setup).
Check out developer.opto22.com to get the outline on installing mariadb on EPIC.
Once thats up and running, you will need the mySQL node, install it via the palette manager in Node-RED.
Once that is done and configured, you can then format your data that you want to insert in the Node-RED flow. Lots of examples for that here in the forums or on our Opto22 YouTube channel.
For select statements, you would use the function node and set the msg.topic to get the data you are looking for.
Is the catch node indicating that the connection has failed not sufficient to know when the DB is not up? Is there something else you’re looking for?
Also, beyond just checking the status, do you know what is causing the connection loss? Is it server side? Network related? Are the nodes being overloaded with statements?
You could reduce the 17 connections by using link nodes or otherwise reworking your flow.
I couldn’t get the catch node to only look at the 1 node-red-node-mysql node. The catch node would overflow with errors because it was catching all 17.
I was able to make it work by adding a different type of MySQL node (node-red-contrib-stackhero-mysql)…adding the catch node with a function node to parse the error and email it.
This is a preventive measure. Our customer’s operation comes with large penalties for downtime. We want to know if we have a database issue as soon as possible.
To test, I was stopping the MariaDB using an exec node to issue sudo /etc/init.d/mysqld stop .
For my edification…I have used the code in my first post on Node-Red instances running on a computer. Is it not possible to load node package managers in the groovEpic PR1 Node Red …and make connections via function blocks?
I think you have to name all the nodes different, and then the catch node can be set to catch each one by its name.
17 connections to the same DB on a remote PC sounds odd. I suspect we are not really understanding your setup very well.
Sorry that your first post gave me the impression that the mariadb was installed on the EPIC.
Sounds like your Windows PC that you ran the initial Node-RED code on also had mySQL drivers on it, so that explains why that worked.
Yes, EPIC (really has nothing to do with EPIC, its more a remote Node-RED question) could be made to work much the same, if I am understanding your system build correctly… mySQL on a remote PC and Node-RED on an EPIC at another location. Depends on your network setup to some extent. ie, remote db connections.