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

Error: Invalid JSON RPC response: "" #1470

Closed
zo-tahiana opened this issue Mar 16, 2018 · 21 comments
Closed

Error: Invalid JSON RPC response: "" #1470

zo-tahiana opened this issue Mar 16, 2018 · 21 comments

Comments

@zo-tahiana
Copy link

zo-tahiana commented Mar 16, 2018

Hello,

I make this code for watching the event Submission but I have the error: Error: Invalid JSON RPC response: ""

    const contract = this._web3.eth.contract(abi).at(address);
    contract.Submission({}, { fromBlock: 0, toBlock: 'latest' }).watch((error, result) => {
      if (error) return console.error(error);
      console.log('on watch');
      console.log(result);
    });

I'm using web3 v0.19.1

Thanks !

@arashkiani
Copy link

I'm having the similar issue when I run this "Error: Invalid JSON RPC response: undefined"

const ganache = require('ganache-cli')
const Web3 = require('web3')
const web3 = new Web3();
web3.setProvider(ganache.provider());
console.log(web3.eth.coinbase);

@arashkiani
Copy link

Check your web3 version in package.json , I've switched it to ^1.0.0-beta.31 and its all golden now.

@iurimatias
Copy link
Contributor

@zo-tahiana did you solve this? can you provide info on what node you are connecting to?

@michelem09
Copy link

I have the same issue polling regularly a Parity node (ETH), sometimes I receive this error, but not always:

web3: 1.0.0-beta.34
Node.js: 9.8.0
Parity: v1.9.6-20180416

ERR app/modules/systems/server/systemSockets/systems-monitor.server.socket.config.js Error: Invalid JSON RPC response: ""
        at Object.InvalidResponse (app/node_modules/web3-core-helpers/src/errors.js:42:16)
        at XMLHttpRequest.request.onreadystatechange (app/node_modules/web3-providers-http/src/index.js:73:32)
        at XMLHttpRequestEventTarget.dispatchEvent (app/node_modules/xhr2/lib/xhr2.js:64:18)
        at XMLHttpRequest._setReadyState (app/node_modules/xhr2/lib/xhr2.js:354:12)
        at XMLHttpRequest._onHttpRequestError (app/node_modules/xhr2/lib/xhr2.js:544:12)
        at ClientRequest.<anonymous> (app/node_modules/xhr2/lib/xhr2.js:414:24)
        at ClientRequest.emit (events.js:180:13)
        at ClientRequest.emit (domain.js:421:20)
        at Socket.socketErrorListener (_http_client.js:394:9)
        at Socket.emit (events.js:180:13)
        at Socket.emit (domain.js:421:20)
        at emitErrorNT (internal/streams/destroy.js:64:8)
        at process._tickCallback (internal/process/next_tick.js:114:19)

@zo-tahiana
Copy link
Author

Thank you for your help. I solve it by upgrading the web3 version to latest. So, I will close this issue.

@mingxuanM
Copy link

@michelem09 did you solve this? I have exactly the same error message, with the latest web3 version.

@michelem09
Copy link

No I still have this

@xjerod
Copy link

xjerod commented May 29, 2018

I'm having this issue as well querying a Geth Ropsten node. What's odd is that I was querying the node just fine, then I restarted the node and now I can't query it.

Node v10.0.0
Web3 1.0.0-beta.34
Geth 1.8.6-stable

EDIT:

I found my issue, although it was a stupid error on my part I'm leaving this up incase anyone else happens to have the same issue.

I had conflicting env vars which were overriding the host+port I was connecting to, and pointing it towards a node that wasn't up anymore.

So this is more of a case of a very bad error message (invalid json rpc vs connection refused)

@IMRFeng
Copy link

IMRFeng commented Jul 12, 2018

Yes, agreed with @jrbury, that wired message was fired when the connection was refused or timeout, and it would be nice to have a meaningful error message returned in that case I think.

@padmasreenagarajan
Copy link

i too get the same response.please provide me a solution.
my version is web3@1.0.0-beta.35

@arashkiani
Copy link

check your code making sure you are using the web3 v1 syntax

@padmasreenagarajan
Copy link

padmasreenagarajan commented Aug 14, 2018 via email

@padmasreenagarajan
Copy link

I'm closing the issue..I got error because i have'nt declared the correct port.it's working fine now.thanks

@john-osullivan
Copy link

In case other debuggers hit this, I was SSHing into a node of a private network and thought I could use localhost -- turns out that you need to use the RPC address specified in the command-line args. Switching over fixed the issue.

@sushanth3366
Copy link

"name": "inbox",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC",
"dependencies": {
"ganache-cli": "^6.3.0",
"mocha": "^4.1.0",
"solc": "^0.4.17",
"truffle-hdwallet-provider": "^1.0.4",
"web3": "^1.0.0-beta.36"
}
}

deploy.js
const HDWalletProvider = require('truffle-hdwallet-provider');//HDWallet says which account we wnat to unlock and which account to use as source of ether and which account to be unlockedfor deploying our constract and what outside node we are gng to connect to
const Web3=require('web3');
const{interface,bytecode}=require('./compile');
const provider=new HDWalletProvider(
'uniform parrot race entry worry saddle during buyer source wait invest slight','https://rinkeby.infura.io/v3/de97edd91145471199555841549fb3bc'
);
const web3=new Web3(provider);//we can use web3 instance to interact with test network we can send eth,deploy contract etcv

// reason we are writing function so that we can avoid promises and use async await
const deploy=async ()=>{
const accounts= await web3.eth.getAccounts();
console.log('attempting to deploy from account',accounts[0]);
const result=await new web3.eth.Contract(JSON.parse(interface))
.deploy({data:'0x'+ bytecode,arguments:['hi! there']})
.send({gas:'1000000',from:accounts[0]});

console.log('contract deployed at',result.options.address);//to know where our contract is deployed

};
deploy();

ERROR IAM GETTING WHEN I RUN ABOVE CODE
kuras-MBP:inbox kurasushanthkumarreddy$ node deploy.js
attempting to deploy from account 0xAe458357763F80a7aAa72F80339911D9Bf48320b
contract deployed at 0x6d31980F771424AaDE60CfAeB961FdD5CF333f78
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:625357)
at e.i.onreadystatechange (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:775475)
at e.t.dispatchEvent (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:1:152983)
at e._setReadyState (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:780284)
at e._onHttpRequestError (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:783952)
at ClientRequest. (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:781449)
at ClientRequest.emit (events.js:189:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:625357)
at e.i.onreadystatechange (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:775475)
at e.t.dispatchEvent (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:1:152983)
at e._setReadyState (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:780284)
at e._onHttpRequestError (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:783952)
at ClientRequest. (/Users/kurasushanthkumarreddy/inbox/node_modules/truffle-hdwallet-provider/dist/index.js:15:781449)
at ClientRequest.emit (events.js:189:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

@richasahu14
Copy link

@sushanth3366 Did you solve the issue, I am getting the same problem.

@richasahu14
Copy link

If anybody else has solved the issue mentioned by @sushanth3366. Please write back.

@pironmind
Copy link

Check the current provider and expected provider

I'm having this issue as well querying a Geth Ropsten node. What's odd is that I was querying the node just fine, then I restarted the node and now I can't query it.

Node v10.0.0
Web3 1.0.0-beta.34
Geth 1.8.6-stable

EDIT:

I found my issue, although it was a stupid error on my part I'm leaving this up incase anyone else happens to have the same issue.

I had conflicting env vars which were overriding the host+port I was connecting to, and pointing it towards a node that wasn't up anymore.

So this is more of a case of a very bad error message (invalid json rpc vs connection refused)

@BarneyChambers
Copy link

Note to my future self when I forget again and look this up, AND anyone else still having this problem: If you are using Geth make sure to run geth in RPC mode geth --rpc so that you can use the RPC api otherwise this error will occur

@parin13
Copy link

parin13 commented Aug 21, 2020

I was getting same issue with : web3V1.2.11,
rolled back to web3v1.2.1 solved the issue

@ArtixZ
Copy link

ArtixZ commented Oct 1, 2020

@parin13 I had same issue at V1.2.11 upgraded to V1.3 - it's working now

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