Skip to content

Conversation

Dustin4444
Copy link

@Dustin4444 Dustin4444 commented Apr 10, 2025

Fixes #1053

Implement WebSocket reconnection and keep-alive mechanism in WebSocketProvider.

  • Add onclose, onping, and onpong event handlers to handle WebSocket close events and maintain connection.
  • Utilize the #connect method for reconnection purposes.
  • Add logic to re-establish subscriptions and pending requests on reconnection.
  • Include a keep-alive mechanism with ping-pong to maintain the WebSocket connection.
  • Modify src.ts/providers/provider-websocket.ts and lib.esm/providers/provider-websocket.js to reflect these changes.

For more details, open the Copilot Workspace session.

Fixes ethers-io#1053

Implement WebSocket reconnection and keep-alive mechanism in `WebSocketProvider`.

* Add `onclose`, `onping`, and `onpong` event handlers to handle WebSocket close events and maintain connection.
* Utilize the `#connect` method for reconnection purposes.
* Add logic to re-establish subscriptions and pending requests on reconnection.
* Include a keep-alive mechanism with ping-pong to maintain the WebSocket connection.
* Modify `src.ts/providers/provider-websocket.ts` and `lib.esm/providers/provider-websocket.js` to reflect these changes.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ethers-io/ethers.js/issues/1053?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocketProvider handle ws close and reconnect
1 participant