I am using onLogs
(https://solana-labs.github.io/solana-web3.js/classes/Connection.html#onLogs) to listen to interactions with my program. I am connecting to the blockchain via a paid RPC and performing server-side logic depending on how someone interacted with my Solana program.
This is the only way I can think of to maintain a web2/web3 application where the client on the front-end does stuff, and my server listens to logs emitted by my program to update the db, perform business logic, etc.
However, how do I know if the onLogs connection drops randomly? How can I handle reconnecting and listening to the program again? The documentation does not provide any relevant information.
If my entire application is dependent on listening to logs emitted by my program after actions done on the blockchain, how do I make sure my business doesnt collapse because the socket connection with the onLogs
event listener suddenly fails?
Is my approach just inherently flawed, is there a better way to do this? if not how do i handle when the onLogs
connection does drop?