Intermittently the app can't establish new wss connections
We've noticed this while developing. Reviewing the app's network connections showed a lot of extra\unused websockets being opened. This PR cleans those up, the idea being that maybe the rpc servers are limiting socket count per client. (It's also just good to cleanup the extra sockets of course!)
If the app isn't used for 60 seconds, established websockets "timeout" and close
The problem here seems to be the rpc servers terminating sockets after one minute of no activity. We're using ethersjs for our rpc client which doesn't currently have logic to auto-reconnect closed sockets (https://github.com/ethers-io/ethers.js/issues/1053). So for now, I added a "keepAlive" function that requests the current block number every 55 seconds.
Intermittently the app can't establish new wss connections
We've noticed this while developing. Reviewing the app's network connections showed a lot of extra\unused websockets being opened. This PR cleans those up, the idea being that maybe the rpc servers are limiting socket count per client. (It's also just good to cleanup the extra sockets of course!)
If the app isn't used for 60 seconds, established websockets "timeout" and close
The problem here seems to be the rpc servers terminating sockets after one minute of no activity. We're using ethersjs for our rpc client which doesn't currently have logic to auto-reconnect closed sockets (https://github.com/ethers-io/ethers.js/issues/1053). So for now, I added a "keepAlive" function that requests the current block number every 55 seconds.