I am using infura for connecting to testnet/mainnet as my server side web3 provider.
This works for most requests and operations, but it does not seem to work for Events.
const allEvents = (event, callback) =>
event({}, { fromBlock: 0, toBlock: 'latest' }).get((error, results) => {
if (error) return callback(error);
results.forEach(result => callback(null, result));
event().watch(callback);
});
allEvents(contractInstance.Event, eventCallback);
The code above runs locally (connecting to a localhost:8545 provider / geth) but does not run if I use infura:
// THIS DOES NOT WORK:
const web3Url = `https://ropsten.infura.io/${infuraKey}`;
const web3 = new Web3(new Web3.providers.HttpProvider(web3Url));
// THIS WORKS:
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
Any suggestions or alternatives for web3 providers? Thanks.