Open StarNeit opened 6 years ago
What RPC call were you making with this can you show us your code?
Same case, on call to eth_sendTransaction server returns status 405, then web3.js returns invalid JSON RPC response. What is the reason?
@fxsecltd We don't support eth_sendTransaction
since that requires us to have your private key. You need to use eth_sendRawTransaction
instead.
when I use truffle and truffle-hdwallet-provider to migrate, there is the error http://truffleframework.com/tutorials/using-infura-custom-provider I don't know why, @egalano
when I use remix and metamask, it works
I found when I use proxy in terminal, then it works!!!
@demisstif dow did it work? can you show me ?
@demisstif can you help me , and tell me more
I'm getting the bang same issue using the HDWalletProvider
in truffle. I've tried updating the dependancies to the latest versions, re-checked everything.
I've not actually seen this work for me since I moved to use Infura, I'm going to keep trying and post any thing I find.
Hey @jleeh im going to try to reproduce this issue and see if I can help figure out what the issue is.
I've found my issue, typically it was a very simple one! I didn't remove the "from" within ropsten when migrating over to use Infura in truffle.js.
the same error. Happened when I try to connect to infuro ropsten('https://ropsten.infura.io/'), I am using web3@0.20.6 , then watch contract event.
const ethereumUri = 'https://ropsten.infura.io/';
let web3Provider = new Web3.providers.HttpProvider(ethereumUri);
let web3 = new Web3(web3Provider);
//initContract
let OracleAPI = fs.readFileSync(__dirname + "/../build/contracts/OracleAPI.json");
let OracleAPIContract = contract(OracleAPI);
OracleAPIContract.setProvider(web3Provider);
let OracleAPIContractInstance;
OracleAPIContract.deployed().then((instance) => {
OracleAPIContractInstance = instance;
var PartnerAdded = OracleAPIContractInstance.PartnerAdded({});
PartnerAdded.watch((error, result) => {
if (!error && result) {
Util.debug('');
Util.debug('PartnerAdded ================== ');
var newPartner = web3.toBigNumber(result.args.newPartner);
Util.debug('newPartner: ' + newPartner.toString(16));
} else {
console.log(error);
Util.error(error);
}
});
var Sendout = OracleAPIContractInstance.Sendout({});
Sendout.watch((error, result) => {
if (!error && result) {
Util.debug('');
Util.debug('Sendout ================== ');
var address = web3.toBigNumber(result.args.address);
Util.debug('address: ' + address.toString(16));
var value = web3.toBigNumber(result.args.value);
console.log('value: ' + value.toString(10));
} else {
console.log(error);
}
});
console.log('event watched');
}).catch((err) => {
console.log(err);
});
any idea?
const Web3 = require('web3');
const fs = require('fs');
const solc = require('solc');
let web3;
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/my key'));
}
const source = fs.readFileSync('./contract/coin.sol', 'utf8');
const compile = solc.compile(source, 1);
const contractCompile = Object.values(compile.contracts)[0];
const deployAddr = '0x.....';
const contractByteCode = '0x' + contractCompile.bytecode;
const contractAbi = JSON.parse(contractCompile.interface);
const gasEstimate = web3.eth.estimateGas({data: contractByteCode});
const gasPrice = '20000000000';
const myContract = new web3.eth.Contract(contractAbi, {
from: deployAddr,
gas: '15000000',
gasPrice: gasPrice,
});
const initialSupply = 10000000000;
const tokenName = 'LLT';
const tokenSymbol = 'LLT';
myContract.deploy({
data: contractByteCode,
arguments: [initialSupply, tokenName, tokenSymbol]
}).send({
from: deployAddr,
gas: '15000000',
gasPrice: gasPrice
}, function (error) {
console.log(error);
})
.on('transactionHash', function (transactionHash) {console.log(transactionHash)})
.on('receipt', function (receipt) {
console.log(receipt.contractAddress) // contains the new contract address
}).on('confirmation', function (confirmationNumber, receipt) {
}).then(function (newContractInstance) {
console.log(newContractInstance.options.address) // instance with the new contract address
}).catch(err => {
console.log("Error: failed to deploy, detail:", err)
});
Error: Invalid JSON RPC response: "" when I use node to run this code
For those using truffle this was apparently fixed with version 4.1.9. Truffle issue [here] (https://github.com/trufflesuite/truffle/issues/852)
Using truffle 4.1.13 and the issue persists.
Truffle v4.1.13 (core: 4.1.13) Solidity v0.4.24 (solc-js) Still have the issue every once awhile
Seems also reported on #135. not sure if completely duplicated
I have the same problem. Occurs on Ropsten and Rinkeby. But both local Ganache and Ganache-Cli networks works fine.
Still no resolution on this? I get the same error as everybody else, using any of the testnets. (works on local testrpc though, but still not helpful)
Can somebody on the dev team please at least come up with a more descriptive error message?
emmmmm....I reopened my pc, and I could run normally. I have no idea about this.... Maybe it also can work for you.
To everyone.
Note: the following information may not be correct. It's based on a the huge amount of time I have spent battling the "Invalid JSON RPC response" error but since I don't know the exact cause of the error, I can't be certain about my theories below. I have reported my latest problems with that error on the issues shown below. But in my case it is happening with Ganache only since I have not progressed to the point where I can deploy to a non-local network like @DavidVotrubec has.
https://github.com/trufflesuite/ganache-cli/issues/611
https://github.com/ethereum/web3.js/issues/2135
I have had the "InvaliD JSON rpc Response" problem on and off during the last 8 months of Ethereum development. Unfortunately I am back having it again. In my opinion, the reason why you don't get a more descriptive error message as @hdany mentions is because it happens at a very low level, at the TCP socket communication level.
During a recent debugging trial I hung Wireshark, a port monitor program, on the Ganache RPC request port. What I saw was the server terminating the socket connection used for RPC queries with an RST response
, the TCP protocol response that indicates that server rejects the request or is unavailable to service it at the current time. The net result is rather than the server handling the request at a place that it expects to have errors, where it would issue a sensible error message, something is wrecked internally so the connection is just dropped. In other words, the server code most likely "crashed" in an unexpected way.
This results in the Web3JS code getting an empty response since the server didn't send one and that leads to the InvalidResponse/"Invalid JSON RPC response" error on the Web3JS side. Web3JS can't give a better error message because it didn't get anything useful back from the server.
Since it is happening to @DavidVotrubec on non-local networks like Rinkeby and Ropsten, this indicates that instead of the problem being due to specifically the Ganache server dropping the connection as in my case, in his case the problem is happening on one of Infura's gateway servers to the Ethereum network(s). There may be absolutely no relation between the causes of the "Invalid JSON RPC error" on the server side across all our cases. The only commonality is that it's a server error that is so bad that it causes the server to just drop the connection, or anything else along the way.
The only suggestion I have here is that Web3JS should enhance the error text to something like:
"Invalid JSON RPC response. Server dropped the connection unexpectedly resulting in an empty response from the server."
Error: Invalid JSON RPC response: "" 4|bwcoin_p | at Object.InvalidResponse (/var/www/xxx/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/errors.js:35:16) 4|bwcoin_p | at XMLHttpRequest.request.onreadystatechange (/var/www/xxx/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/httpprovider.js:115:32) 4|bwcoin_p | at XMLHttpRequestEventTarget.dispatchEvent (/var/www/bwcoin/node_modules/xhr2/lib/xhr2.js:64:18) 4|bwcoin_p | at XMLHttpRequest._setReadyState (/var/www/bwcoin/node_modules/xhr2/lib/xhr2.js:354:12) 4|bwcoin_p | at XMLHttpRequest._onHttpResponseEnd (/var/www/bwcoin/node_modules/xhr2/lib/xhr2.js:509:12) 4|bwcoin_p | at IncomingMessage. (/var/www/bwcoin/node_modules/xhr2/lib/xhr2.js:469:24)
4|bwcoin_p | at emitNone (events.js:91:20)
4|bwcoin_p | at IncomingMessage.emit (events.js:185:7)
4|bwcoin_p | at endReadableNT (_stream_readable.js:974:12)
4|bwcoin_p | at _combinedTickCallback (internal/process/next_tick.js:80:11)
4|bwcoin_p | at process._tickDomainCallback (internal/process/next_tick.js:128:9)
Everything was working fine a few hours ago, but it is not working now. Any help please?