CONNECTION ERROR: Couldn't connect to node on WS with "wss://"

it working when run rinkeby or ropsten but error "Couldn’t connect to node on WS " with mainnet. Someone can help me. Thanks

Can you provide your code generating the WS connection and the full error response?

This is picture error when connect to websocket mainnet. While I connect to testnet still working.

When trying to onEvent from contract, it gets ‘end connect socket’.
Before that, it still works normally.

I use web3@1.0.0-beta.33

This is code

var Web3 = require(‘web3’);
var provider = new Web3.providers.WebsocketProvider(“wss://”, 30000)
var websocket = new Web3(provider)

var ABI = […];
var address = ‘…’;

provider.on(“connect”, ()=>{
let socket_contract = new websocket.eth.Contract(ABI, address);{fromBlock:7922783,toBlock:‘latest’},async function (error,events) {
console.log('Error Main Core: ',error);
}else {

provider.on(“end”, ()=>{
console.log(“provider end”)

Hope you can help me.

Couple things to try,

  • Update to the latest version of web3.js
  • web3,js is using a filter not a subscription, it is possible this is causing the timeout, how much time passes before you receive this error?


I’ve confirmed that I could connect to mainnet using your v3 key (wss://

Jee$ wscat -c wss://
connected (press CTRL+C to quit)

I also tried using web3@1.0.0-beta33 and tried getting allEvents from another contract I have access to. ( I couldn’t use your ABI or address since it’s not part of your code snippet) I used your exact same code but with just another abi and address and I’m currently getting events.

Let me know if there’s something else we could try to help you debug this.