So I have a dapp that includes a node server, which I have got to work successfully using ganache, using this line:
web3 = new Web3(new Web3.providers.WebsocketProvider('http://127.0.0.1:8545'))
I have deployed my project to ropsten and would like to use infura for that, so I changed the code to:
web3 = new Web3(new Web3.providers.WebsocketProvider('wss://ropsten.infura.io/v3/PROJECTID'))
Obviously I did use my actual projectID. But I get this error: " UnhandledPromiseRejectionWarning: Error: connection not open". This is the same error I get when I use my localhost URL but forget to start ganache.
I know that my infura is set up properly because I am able to successfully migrate my project using truffle using the "https://ropsten.infura.io/v3/PROJECTID" endpoint.
As a test I tried to connect via http instead of wss, ie using this line:
web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/PROJECTID'))
and this gives me a DIFFERENT error: "UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'returnValues' of null"
Wat do? I'm using my node server to listen for events, so I'm not sure if I can use http even if it did work- I believe that I need to use websockets for events.