Problem with server side call to Ethereum node


I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3)



if (typeof web3 === ‘undefined’){
web3 = new Web3(new Web3.providers.HttpProvider(‘’));


web3.eth.defaultContractEvent = “0x*************************************”;
contract_event = web3.eth.contract(abi_event).at(web3.eth.defaultContractEvent);
var events = contract_event.allEvents({fromBlock: 0, toBlock: ‘latest’});

get error at last line


TypeError: XHR2 is not a function
at [object Object].HttpProvider.prepareRequest (packages\ethereum_web3.js:4315:15)
at [object Object].HttpProvider.sendAsync (packages\ethereum_web3.js:4364:22)
at [object Object].RequestManager.sendAsync (packages\ethereum_web3.js:6369:19)
at Object.send [as newFilter] (packages\ethereum_web3.js:5080:42)
at new Filter (packages\ethereum_web3.js:3568:25)
at [object Object].AllSolidityEvents.execute (packages\ethereum_web3.js:2716:12)

at server/main.js:135:30

at Function.time (C:\***\.meteor\local\build\programs\server\profile.js:309:28)
at C:\***\.meteor\local\build\programs\server\boot.js:348:13
at C:\***\.meteor\local\build\programs\server\boot.js:389:5

Exited with code: 1

what is the problem?


This might be similar to a problem I was having. I think your issue might be specific to the version of web3 that you are using. Feel free to take a look at my SO question: Missing Web3 Meteor Server