let web3 = new Web3(
// Replace YOUR-PROJECT-ID with a Project ID from your Infura Dashboard
new Web3.providers.WebsocketProvider(“wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID”)
);
Trying above giving me error as
web3.providers.WebsocketProvider is not a constructor My npm web3 version is “0.20.7”
Do change this code will affect my all API? Have you tried swapping your key,
Can you tell me which key?? ( is this key is Project ID ?)
Hi @Leiya_Kenney thanks for reply,
yes i have tried swapping Project ID, we were using free account first, but now we have taken “developer” plan ( 2lahk request per day ). But no luck with using new Project Id. Request are so high
@sacgrover and @jmonteer - we’re still working to figure it out. Are you using web3-provider-engine by any chance? If not, can you please provide a code snippet of the code with the high eth_getBlockByNumber calls?
Hi everyone,
Same issue here. Enormous requests were sent just in 1 hour of testing - eth_getBlockByNumber
2,452. Looking forward hearing about the potential reason
UPD: figured out, the issue was with HDWalletProvider. Just stopped using it and all is fine. Perhaps it uses web3 subproviders and they do smt strange…
Hi everyone,
I was experiencing the same problem when using Truffle HD Wallet provider. After some troubleshooting, I realised that the object returned from the wallet provider has a property called _pollingInterval which determines the interval to poll the state of the blockchain (this is what uses up so many requests).
This value can be manually adjusted to something like 1800000 (30 minutes) with the following code before passing the provider object into web3:
provider.engine._blockTracker._pollingInterval = 1800000;
Where provider is the object returned by Truffle HD Wallet provider when creating an instance of it. This seems to have no negative impact on interacting with the blockchain and dramatically reduces the requests to Infura. Hope this helps.
Hello TheAndrei
i have the same issue but when i added it to the truffle-config i still get 1000s of requests Screenshot - 9fd8a36f5ac27cc685a2422aae29f90e - Gyazo
how/where am i adding
provider.engine._blockTracker._pollingInterval = 1800000; ??