Registry / messaging / easy-websocket-c

easy-websocket-c

JSON →
library0.4.10jsnpmunverified

A lightweight TypeScript library simplifying WebSocket connections with built-in heartbeat keep-alive and automatic reconnection. Current stable version is 0.4.10, released as an npm package. Key differentiators: minimal API surface, heartbeat detection, automatic reconnection when network is restored (online reconnection), and configurable retry intervals. Suitable for real-time applications needing reliable WebSocket connections. Release cadence is ad-hoc; primarily maintained by a single contributor.

npm install easy-websocket-c
INSTALL
IMPORT
SIG · EASY-WEBSOCKET-C
E
easy-websocket-c
messagingjavascriptv0.4.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EasyWebSocketC
import { EasyWebSocketC } from 'easy-websocket-c'
const EasyWebSocketC = require('easy-websocket-c')
Default export is not available; always use named import. ESM only, no CommonJS support.
EasyWebSocketCOptions
import type { EasyWebSocketCOptions } from 'easy-websocket-c'
import { EasyWebSocketCOptions } from 'easy-websocket-c'
EasyWebSocketCOptions is a TypeScript type; use import type to avoid runtime inclusion.
AutoContect
import type { AutoContect } from 'easy-websocket-c'
import { AutoContect } from 'easy-websocket-c'
AutoContect is a TypeScript type; use import type.

Shows instantiation with options, opening a connection, event handlers, sending a message, and closing.

import { EasyWebSocketC } from 'easy-websocket-c'; const ws = new EasyWebSocketC({ autoContect: { onlineContect: true, max: 0, timeContect: 3000 } }); ws.open('wss://echo.websocket.org') .onOpen(() => { console.log('connected'); }) .onMessage(msg => { console.log('received:', msg.data); }) .onError(err => { console.error(err); }) .onClose(ev => { console.log('closed', ev.code); }); // Send a message ws.send('Hello, server!'); // Close connection ws.close();
Debug
Known issues
gotchaThe option spelling is 'autoContect' (missing 'n' in 'Connect') — not 'autoConnect'. This is inconsistent and may cause confusion.
fix
Use 'autoContect' as the property name exactly as documented.
affects: >=0.1.0
gotchaThe 'open' method accepts 'forceOpen' as a third parameter; if set to true, it will close any existing connection before opening, which may cause unexpected disconnections.
fix
Only set forceOpen to true when you intend to forcefully replace an existing connection.
affects: >=0.1.0
gotchaThe 'reopen' method uses the previous URL and protocols; if you need a different URL, you must call 'open' again with the new URL.
fix
Use 'open' with desired URL to change the endpoint; 'reopen' only reuses previous settings.
affects: >=0.1.0
gotchaThe library does not expose a 'close' method returning a promise; it returns void. Error handling after close must be done via 'onClose' callback.
fix
Use 'onClose' to listen for close events rather than relying on a returned promise.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: EasyWebSocketC is not a constructor
Importing the package incorrectly (e.g., default import instead of named import).
fix
Use named import: import { EasyWebSocketC } from 'easy-websocket-c'
Cannot find module 'easy-websocket-c' or its corresponding type declarations.
Missing TypeScript types; the package ships types but they may not be resolved if your tsconfig is misconfigured.
fix
Ensure 'types' field in tsconfig or 'types' property in package.json is correctly set, or install @types/easy-websocket-c if separate (not needed).
Property 'autoContect' does not exist on type '{ autoConnect: boolean | AutoContect }'
TypeScript complains because the type definition uses 'autoContect' with typo, but your code uses 'autoConnect' (correct spelling).
fix
Change your option property name from 'autoConnect' to 'autoContect' to match the library's exported type.
Upgrade
Version history
0.4.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
easy-websocket-c — npm install easy-websocket-c · libregistry