0

The following example does not hang.

$ cat main.js 
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.getAccounts()
    .then((accounts) => {
        console.log(accounts);
    })

But the following code hangs. Does anybody know why?

$ cat main.js 
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:

const web3 = new (require('web3'))("ws://localhost:8545");
web3.eth.getAccounts()
    .then((accounts) => {
        console.log(accounts);
    })
  • that's a javascript issue please refer to this: stackoverflow.com/questions/20787074/… – mirg Apr 11 '18 at 7:38
  • for websockets default port is 8546, if you are running geth node. btw how you have configured your geth node. – kherwa Apr 11 '18 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.