ethers.js
ethers.js copied to clipboard
Handle WebSocket close and reconnect in WebSocketProvider
Fixes #1053
Implement WebSocket reconnection and keep-alive mechanism in WebSocketProvider.
- Add
onclose,onping, andonpongevent handlers to handle WebSocket close events and maintain connection. - Utilize the
#connectmethod 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.tsandlib.esm/providers/provider-websocket.jsto reflect these changes.
For more details, open the Copilot Workspace session.