changes to keep the ws connection alive with a ping #663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses a couple separate problems:
Infura drops idle ws connections after approximately 60 seconds, unfortunately quietly for the client, never triggering
on-disconnect
Infura uses a cache of events, but presumably only for some of the web3 RPC calls. This manifested because when processing events we use
eth_getblockbynumber
to get the event timestamp.This would throw a fatal exception (only when processing latest events), because even though they arrived the block was presumably not yet cached by infura.
SqliteError: NOT NULL constraint failed: param_changes.param_change_SLASH_original_value #664
Ad 1) is addressed by altering the
server-web3-library
and adding a continuous keep-alive poll. Should it ever encounter an exception, the system goes into an offline mode and starts polling for the connection to go back online. For monitoring purposes I started logging the number of resyncs due to websocket connection dropping. We also detect theon-disconnect
event but as shown before it's not to be trusted 100%.Ad 2) I added a
wait-for-block
function inserver-smart-contracts
library, which polls until the block is availiable.Ad 3) changed the model (reason field can be nil)