A JavaScript SDK for WebSocket communication with automatic reconnection, heartbeat monitoring, and subscription support. Current version 0.4.3. The package provides a simple client that handles connection lifecycle, reconnection with configurable attempts and delays, and heartbeat tracking to detect disconnections. It emits events for 'connect', 'disconnect', 'message', and 'close'. Key differentiator: built-in heartbeat and reconnection logic out of the box. Suitable for real-time applications requiring persistent WebSocket connections.
npm install vietanh-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import and use socketClient to connect, subscribe, and handle messages.
Use client.on('message', callback) instead of onMessageCallback option.Check client.isConnected() before calling connect(), or call close() first.
Use import syntax or set type:"module" in package.json.
Ensure the URL starts with 'ws://' or 'wss://'.
Validate wsKey on the server side; client will connect regardless.
Change to ES import: import { socketClient } from 'vietanh-websocket'Use correct casing: import { socketClient } from 'vietanh-websocket'Add "type": "module" in package.json or rename file to .mjs
No dependency data recorded yet.