Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to keep the ws connection alive with a ping #663

Merged
merged 4 commits into from
Dec 6, 2019

Conversation

fbielejec
Copy link
Contributor

@fbielejec fbielejec commented Nov 28, 2019

Summary

This PR addresses a couple separate problems:

  1. Infura drops idle ws connections after approximately 60 seconds, unfortunately quietly for the client, never triggering on-disconnect

  2. 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.

  3. 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 the on-disconnect event but as shown before it's not to be trusted 100%.

Ad 2) I added a wait-for-block function in server-smart-contracts library, which polls until the block is availiable.

Ad 3) changed the model (reason field can be nil)

@fbielejec fbielejec merged commit 7416b73 into master Dec 6, 2019
@fbielejec fbielejec deleted the fix/keep-ws-alive branch December 6, 2019 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants