A TypeScript-based WebSocket client wrapper that provides automatic reconnection and ping/pong support with a familiar event-driven API. The library is currently at version 2.0.0 and is actively maintained. It differentiates itself by offering a straightforward interface similar to native WebSocket, automatic handling of JSON serialization/deserialization, and configurable heartbeat functionality. Ideal for real-time applications requiring robust network resilience.
npm install resilient-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This example shows how to create a ResilientWebSocket client with JSON serialization and ping/pong enabled, and listen for connection, message, close, and error events.
Set 'pingEnabled: true' or implement custom heartbeat.
Set 'autoJsonify: false' to send raw strings or binary data, or ensure you only send JSON-friendly data.
Use import syntax instead of require().
Use WebSocketEvent.RECONNECT instead.
Call rSock.connect() or rely on event listener to trigger connection.
Set a finite 'maxReconnectAttempts' (e.g., 10) in options.
Change to 'import ResilientWebSocket from 'resilient-websocket'' and ensure your project uses ESM or dynamic import.
Only call send() inside the 'CONNECTION' event handler or after connect() resolves.
Verify the URL (e.g., ws:// or wss://) and that the server is running.
No dependency data recorded yet.