Just now when I use HttpProvider,i got a very strange exception Error: Invalid JSON RPC response: undefined, and I Google it and I got many other answers which are totally useless for my situation. And after a lot of time, I found that because the node server is down. So I open the node and my problem is solved. Then I changed the address into a wrong address, then I got the same error information.
So I wish I can get some more detailed information for the errors instead of an information for many different kinds of errors.
yeah «Invalid JSON RPC response: undefined» is a very bad way of saying
// You need to run a local Ethereum node to use this library.
Could you please provide further informations? for example a code snippet? :)
Here's the code:
var Web3 = require('web3')
var web3 = new Web3()
web3.setProvider(new web3.providers.HttpProvider('http://MY_IP:PORT'));
var Contract_pro = web3.eth.contract(MY_CONTRACT);
module.exports = Contract_pro;
And this code is imported by a mobile application that I was developing. All I could remember was when I was not able to connect to my eth-node, this error would be threw.
I googled it, and find some people have the same error with similar situation -- they got the wrong url or they forgot to open their services. I think a http error might be better not crashing the whole system.
(///â–½///)
The error handling of the HttpProvider got improved. Please update to the latest version of Web3.js.
Most helpful comment
Here's the code:
And this code is imported by a mobile application that I was developing. All I could remember was when I was not able to connect to my eth-node, this error would be threw.
I googled it, and find some people have the same error with similar situation -- they got the wrong url or they forgot to open their services. I think a http error might be better not crashing the whole system.
(///â–½///)