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

Websocket blocks after terminating without unsubscribing #207

Closed
samuel-tay opened this issue Nov 8, 2021 · 5 comments
Closed

Websocket blocks after terminating without unsubscribing #207

samuel-tay opened this issue Nov 8, 2021 · 5 comments
Assignees

Comments

@samuel-tay
Copy link

samuel-tay commented Nov 8, 2021

Describe the bug
As discussed on Discord https://discord.com/channels/783264383978569728/783264902613565450/907267013028749322

It was discovered that subscribing to WS works.

However, if a subscription is not unsubscribed and the session is terminated, then the WS blocks up and no further requests will be entertained. It doesn't help to reconnect and unsubscribe.

Also, in the instance where 2 clients are connected and if Client A terminates the session without unsubscribing, Client B blocks as well, and the whole WS blocks.

To Reproduce
Steps to reproduce the behavior:

  1. Have a local node running
  2. On CLI wscat -c ws://localhost:8546 (response connected)
  3. {"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]} (respond with suscription id)
  4. Ctrl+C to force exit
  5. Repeat 2-3, no response in step 3
  6. Restart node
  7. Repeat steps 2-3
  8. {"id": 1, "method": "eth_unsubscribe", "params": ["(subscriptionid)"]}
  9. Ctrl+C to exit.
  10. Repeat steps 2-3, subscription works

Expected behavior
WS should handle disconnection without blocking.

Screenshots
NA

Desktop (please complete the following information):
Node is Linux

@tomtau
Copy link
Contributor

tomtau commented Nov 9, 2021

this is more likely an issue on Ethermint, I assume: https://github.com/tharsis/ethermint/issues/new?assignees=&labels=&template=bug-report.md
@thomas-nguy @yihuang

@odeke-em
Copy link

odeke-em commented Feb 9, 2022

@yihuang and @thomas-nguy I found the cause of the issue in Ethermint per evmos/ethermint#821 (comment) and it comes from a sync.RWMutex .Lock() being invoked before a .Runlock() is invoked and Go's docs for sync.RWMutex explicitly call out this problem per https://pkg.go.dev/sync#RWMutex
Screen Shot 2022-02-09 at 4 27 33 PM

It'll be fixed shortly in Ethermint.

@odeke-em
Copy link

The fixing PR got merged per evmos/ethermint#933 Can we please close this issue?

@samuel-tay
Copy link
Author

Thanks for this! @odeke-em

@odeke-em
Copy link

Thanks for this! @odeke-em

Cheers, and thank you @samuel-tay!

yihuang added a commit to yihuang/cronos that referenced this issue Feb 21, 2022
yihuang added a commit that referenced this issue Feb 21, 2022
* Problem: Websocket blocks after terminating without unsubscribing

Closes: #207
Solution:
- backport the fix to 0.6.x

* update gomod2nix.toml

* Update CHANGELOG.md

* tag ethermint
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

No branches or pull requests

5 participants