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

add ws reconnection #628

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zzhengzhuo
Copy link

#627

Firstly, run ganache ganache-cli -b 3 -m "hamster coin cup brief quote trick stove draft hobby strong caught unable" --db ./db

  • Test for request
    run example cargo run --package web3 --example transport_ws_loss_connection.
    Got logs
Calling accounts.
Balance of 0xd028d24f16a8893bd078259d413372ac01580769: 99993030720000000000
Balance of 0xd028d24f16a8893bd078259d413372ac01580769: 99993030720000000000

Then restart ganache, got logs:

Get balance failed: Cannot send request. Internal task finished.
Get balance failed: Cannot send request. Internal task finished.
Get balance failed: Cannot send request. Internal task finished.
Balance of 0xd028d24f16a8893bd078259d413372ac01580769: 99993030720000000000
Balance of 0xd028d24f16a8893bd078259d413372ac01580769: 99993030720000000000
Balance of 0xd028d24f16a8893bd078259d413372ac01580769: 99993030720000000000
  • Test for subscription
    run example cargo run --package web3 --example contract_log_filter_loss_connection
    Got logs:
Calling accounts.
contract deployed at: 0xfc62…37fa
got tx: 0xbff1b99fd6615750ead80c19d980191910d86cd5635a86a4a259678cc64f94f8
got tx: 0x056e56e3978879d3d72b7c0e0638e6f1d5cdffc2034897eeb5aa6e5fcd2a8f41
Get log: Log { address: 0xfc62729d4553ddde1ad33eca00b28ac2aef937fa, topics: [0xd282f389399565f3671145f5916e51652b60eee8e5c759293a2f5771b8ddfd2e], data: Bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 40, 210, 79, 22, 168, 137, 59, 208, 120, 37, 157, 65, 51, 114, 172, 1, 88, 7, 105]), block_hash: Some(0x8c2e6059e681ca65faf4b0d2eebbac836c36dcbec6c1c850dc57241138d7362d), block_number: Some(44), transaction_hash: Some(0xbff1b99fd6615750ead80c19d980191910d86cd5635a86a4a259678cc64f94f8), transaction_index: Some(0), log_index: Some(0), transaction_log_index: None, log_type: None, removed: Some(false) }
got tx: 0xcfa5b4c8bc4bf4448e73fb2d7efd4dda5150286146fd2564bb72f976a20e4acb
got tx: 0xc3c3c98760e01143633fc4a5bb4800570cf6358b1ebc0eccc2ffef2643452f66
Get log: Log { address: 0xfc62729d4553ddde1ad33eca00b28ac2aef937fa, topics: [0xd282f389399565f3671145f5916e51652b60eee8e5c759293a2f5771b8ddfd2e], data: Bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 40, 210, 79, 22, 168, 137, 59, 208, 120, 37, 157, 65, 51, 114, 172, 1, 88, 7, 105]), block_hash: Some(0x6f70e5987191d222c6fb056147ce3d9e4e8a6dcb8857a14cb8c3f4c5610ed909), block_number: Some(45), transaction_hash: Some(0x056e56e3978879d3d72b7c0e0638e6f1d5cdffc2034897eeb5aa6e5fcd2a8f41), transaction_index: Some(0), log_index: Some(0), transaction_log_index: None, log_type: None, removed: Some(false) }

Then restarted ganache, got logs:

Log Filter Error: WS connection error: Closed
get tx failed: Api error: Cannot send request. Internal task finished.
get filter failed: Cannot send request. Internal task finished.
get tx failed: Api error: Cannot send request. Internal task finished.
get filter failed: Cannot send request. Internal task finished.
get tx failed: Api error: Cannot send request. Internal task finished.
got tx: 0xeef5ee71c5ed18861cd02763e41ff5a502a8c883e1ad6f754222563763f0b831
got tx: 0x8273a2e8e49b265467a3574420a742e03611049f73f212bc8d588cac72e852c8
Get log: Log { address: 0xfc62729d4553ddde1ad33eca00b28ac2aef937fa, topics: [0xd282f389399565f3671145f5916e51652b60eee8e5c759293a2f5771b8ddfd2e], data: Bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 40, 210, 79, 22, 168, 137, 59, 208, 120, 37, 157, 65, 51, 114, 172, 1, 88, 7, 105]), block_hash: Some(0x98b799d67d909361a9face5e4a917b3b214dce5ecedf1790b76dae75661d4bf4), block_number: Some(46), transaction_hash: Some(0xeef5ee71c5ed18861cd02763e41ff5a502a8c883e1ad6f754222563763f0b831), transaction_index: Some(0), log_index: Some(0), transaction_log_index: None, log_type: None, removed: Some(false) }
Get log: Log { address: 0xfc62729d4553ddde1ad33eca00b28ac2aef937fa, topics: [0xd282f389399565f3671145f5916e51652b60eee8e5c759293a2f5771b8ddfd2e], data: Bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 40, 210, 79, 22, 168, 137, 59, 208, 120, 37, 157, 65, 51, 114, 172, 1, 88, 7, 105]), block_hash: Some(0x98b799d67d909361a9face5e4a917b3b214dce5ecedf1790b76dae75661d4bf4), block_number: Some(46), transaction_hash: Some(0x8273a2e8e49b265467a3574420a742e03611049f73f212bc8d588cac72e852c8), transaction_index: Some(1), log_index: Some(0), transaction_log_index: None, log_type: None, removed: Some(false) }

@ffoxdd
Copy link

ffoxdd commented Jul 19, 2022

Is this still being considered? This would be very useful for me.

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.

None yet

4 participants