[Ethereum] Can’t connect to Infura testnet or mainnet

infuraweb3js

From the Web3 JS API I've written:

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/MYTOKEN"));
console.log(web3.currentProvider);

which produces:

HttpProvider {
  host: 'https://ropsten.infura.io/MYTOKEN',
  timeout: 0,
  connected: false }

So far I've tried removing the token and just using https://ropsten.infura.io, and I've also tried the Infura mainnet and Kovan, neither of which worked.

I suspect this is unrelated to Web3/Infura and maybe related to firewall settings or something? Any help is appreciated.

Best Answer

Switching to version 0.20.3 seemed to solve the issue for me. If you have version 1.0.0 that might be the source of the issue. Web sockets released by Infura seem to be working with version 1.0

Related Topic