very small project - node.js / websocket / mariaDB - modify an example node.js websocket client page so that it will re-subscribe / re-connect / re-boot.
what i want the code to do -
1) check the db pool connection.
2) if no pool connection after # tries, re-boot db - please provide code (commented-out) to re-boot the other pc on my network when it is operational.
3) subscribe to the websocket channel (or re-subscribe if it is a re-start) - don't open websocket unless/until db pool connection is checked (see above).
4) terminate websocket if it fails - use a timeout so that db has time to process any outstanding insert queries.
5) re-subscribe if the subscription fails (eg no data, no heartbeat, no pong).
6) re-boot if re-subscribe/re-connect fails.
7) send email if an event requiring manual attention occurs (eg i have to manually reboot the system).
i need these modifications because i live in a house where :
- the power supply to my router &/or to my computers could be switched off at any time, without any notice, and obviously i won't know about it if i'm not at home or i'm asleep.
- the internet network connection fails several times a day and usually takes 5-10 minutes to reboot itself and then it will have a different ip address so the websocket connection will be lost.
so i need modifications that will enable me to switch the system on and only have to attend it in order to do occasional jobs that must be done manually, eg restoring power or re-booting the router.
the node.js client page simply collects data for trading a single digital currency so that i can process the data and decide if i want to try trading digital currencies :
- if i decide to trade, then i will need someone to code at least two more much larger projects.
- if you make a good job of this project then you will be invited to quote for the larger projects.
read my requirements carefully and don't bid if you are unable to satisfy them all as i don't want to appoint the project to someone who takes a deposit and then says that they can't do part of it for some reason. i have had freelancers do that in the past.
the node.js page uses "books" data stream - i will be using your code with other streams so please use naming system that does not include reference to "books" or "wBooks" so that i can easily use your code with other streams without risk of confusion or conflict.
i have removed all my processing code from the node.js page - my processing code will include a checksum (line 148) so please include option to re-subscribe if checksum is wrong (you don't need to code the checksum).
how i want your code provided -
- properly commented.
- use named functions : do not use arrow functions : do not use anonymous functions.
- written in a style similar to my own (i am an amateur code and it may confuse me if i have to try to understand complex code).
- don't call on external libraries as i don't want to rely on code that i can't see/understand.
- prepare your code in 2 ways - (1) all on one page, and (2) divided into modules for easy reading/understanding.
- don't keep unnecessary weight on the stack : close/terminate/nullify/remove everything that becomes redundant (pool connections, listeners, websockets) after re-subscribe/re-connect.
my computer set-up -
- at the moment, the node.js page & the db are both running on a single linux-based machine.
- once i am happy that your code works well, i intend to add a second linux-based machine to my network and move the db to the second machine.
i hope that all the above is clear. please feel free to ask any questions.
don't bid a silly price. it would just be a waste of your time & mine.