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

Legacy providers only support notification event. when using WebsocketProvider #62

Open
megaturbo opened this issue Aug 27, 2019 · 5 comments

Comments

@megaturbo
Copy link

I'm using the WebsocketProvider and I want to listen to provider events like connect, error, etc...

Right now I'm using this:

import { WebsocketProvider } from "web3x/providers";

const provider = new WebsocketProvider(ws_provider_path);
provider.on("connect", () => console.log("Provider connected."));

But I keep getting this error:

Error: Legacy providers only support notification event.

So why is the WebsocketProvider a legacy provider ? And how can I setup a non-legacy provider to listen to this kind of events ?

@xf00f
Copy link
Owner

xf00f commented Aug 27, 2019

The current websocket provider, is the legacy provider wrapped in an adapter. Unfortunately the adapter is provider agnostic so isn't setup to deal with these new events. EIP 1193 remains a moving target (12 days ago ethereum/EIPs#2240).

Regardless, it's would be useful to have providers that meet the spec as it stands. Unfortunately I don't have time to look into this right now. Happy to look over and accept good quality PR's...

@megaturbo
Copy link
Author

megaturbo commented Aug 27, 2019

Maybe I can help with that, I'll see what I can do when I have time.

For now, do you have any idea how to reconnect the provider after loss of connection ?

@xf00f
Copy link
Owner

xf00f commented Aug 28, 2019

It seems this may be an issue inherited from web3.js.
web3/web3.js#1354

Maybe the provider has been cleaned up and fixed in web3.js and can be migrated in.
Right now not sure what to suggest. I maybe get a chance to look into this in next few weeks.

@takahser
Copy link

takahser commented Dec 8, 2019

any updates on this?

@takahser
Copy link

takahser commented Dec 27, 2020

EIP 1193 remains a moving target

@xf00f looks like EIP-1193 has been finalized: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md

what's the best way to work on this?

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

3 participants