ethrpc
ethrpc copied to clipboard
No error when trying to connect to geth, and no peers.
To reproduce:
- Start geth and make sure there are no peers connected.
- Run
rpc.connect
. - No error returns. hangs forever.
The issue happens because when trying to do the initial connection you do 3 things in parallel, where the first thing is ensureLatestBlock
, and if you look at the code you will see that it fails silently, causing the async.parallel
to hang forever.
I just tried this and was not able to reproduce this issue. ensureLatestBlock
should always pull the latest block the Ethereum node has -- even if it hasn't ever connected to any peers, it will still have the genesis block. Can you give me more details about your setup?
- What network are you on, and what is the latest blocknumber your geth has on that network?
- What command are you using to start geth?
- Which version of geth are you using?
- What OS are you using?
- What is the exact command you're using when you call
ethrpc.connect
? - Are you using ethrpc from Nodejs (if so, which version?) or a browser (if so, which browser and version?)?
- I'm using the main network, the latest blocknumber is
-
geth --syncmode "light" --datadir="c:\ethereum\main" --nousb --rpc console
- 1.7.3-stable
- Windows 10
const rpc = require('ethrpc');
const connectionConfiguration = {
httpAddresses: ['http://localhost:8545'],
wsAddresses: [],
ipcAddresses: []
};
rpc.connect(connectionConfiguration, err => {
if (err) {
console.log('Failed to connect to Ethereum node.');
} else {
console.log('Connected');
}
});
- I'm using NodeJs version 8.9.0
Some more information:
- When I type
admin.peers
on the geth console I get[]
- The
connect
function hangs because theensureLastestBlock
never calls thecallback
, To prove that this is the problem, I changed the code and called thecallback
anyway, and theconnect
did not hang... -
ensureLatestBlock
failed with the error: no suitable peers available, error: -32000