WebSocket is a computer communications protocol providing full-duplex communication channels over a single TCP connection. That being said, Websockets are fragile because they can get disconnected by internet stability, technical limitations, potential bugs, etc.
Best practices for Websockets:
- Implement a ping-pong mechanism to check if the socket to the server is still up and healthy
- Auto reconnect whenever the connection ends
- Monitor the network stability of the host you're running your app from
Web3JS has the ping-pong and auto-reconnect feature build-in that you can find here https://web3js.readthedocs.io/en/v1.7.5/include_package-core.html?highlight=websocket#configuration
If you want to implement it yourself but need a code reference, you can go here https://github.com/ethers-io/ethers.js/issues/1053#issuecomment-808736570
The issue at hand is not Quicknode specific, so there are many threads and discussions you can follow like these
Comments
0 comments
Article is closed for comments.