3

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.

6
  • 1
    Did you try using the command line to send messages to eliminate firewall problems? $ curl -X POST \ -H "Content-Type: application/json" \ --data '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}' \ "mainnet.infura.io/YOUR_ACCESS_TOKEN"
    – larsl
    Commented Jul 30, 2017 at 22:06
  • 1
    have you issued correctly your infura token?
    – Badr Bellaj
    Commented Jul 30, 2017 at 23:12
  • Yes I correctly received my token and was able to get a response for $ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' mainnet.infura.io/MYTOKEN
    – user16306
    Commented Jul 31, 2017 at 0:16
  • This works for me...if this doesn't work for you, try shutting off your firewall (it never connects when mine is on) const Web3 = require("web3"); const web3 = new Web3(new Web3.providers.HttpProvider("ropsten.infura.io"));
    – thefett
    Commented Jul 31, 2017 at 1:14
  • I am having the same issue. Did you ever manage to work it out? Commented Jan 16, 2018 at 5:38

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.