Skip to content

provider ethers.providers.WebSocketProvider losing connection over time #2214

Answered by proficy
proficy asked this question in Q&A
Discussion options

You must be logged in to vote

After some pretty extensive testing the only solution seems to be something like this:

let provider = new ethers.providers.WebSocketProvider('geth node websocket URL');

let testProvider = async () => { 
  let testContract= new Contract(contractAddress, contractAbi, provider);
  let startTime = tomorrow;
  while (true) {
    if (new Date() > startTime) { 
      break;
    }
  }
  provider = new ethers.providers.WebSocketProvider('geth node websocket URL');
  testContract= new Contract(contractAddress, contractAbi, provider);
  let testFunction= await testContract.testFunction();
}

This doesn't seem like intended functionality and I'd like to create an issue for this.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thugzook
Comment options

Answer selected by proficy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants