Registry / messaging / qiao-ws

qiao-ws

JSON →
library6.0.3jsnpmunverified

A Node.js WebSocket library providing a simple API for creating both WebSocket servers and clients. Version 6.0.3 is current, with a focus on ease of use and minimal configuration. It is actively maintained and suitable for real-time communication in Node.js applications. Compared to alternatives like ws or socket.io, qiao-ws offers a more straightforward interface but lacks advanced features such as reconnection or event-based messaging. Ideal for small projects or simple WebSocket integrations.

npm install qiao-ws
INSTALL
IMPORT
SIG · QIAO-WS
Q
qiao-ws
messagingjavascriptv6.0.3
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.

WebSocketServer
import { WebSocketServer } from 'qiao-ws'
const WebSocketServer = require('qiao-ws').WebSocketServer
CommonJS require works but named export destructuring is preferred.
WebSocketClient
import { WebSocketClient } from 'qiao-ws'
const WebSocketClient = require('qiao-ws').WebSocketClient
Same as server; ensure correct casing.
default
import qiaoWs from 'qiao-ws'
const qiaoWs = require('qiao-ws')
Default export is not explicitly defined; using named imports is safer.

Creates a WebSocket server on port 3000 and a client that connects to it.

import { WebSocketServer, WebSocketClient } from 'qiao-ws'; // Server const server = new WebSocketServer({ port: 3000 }); server.on('connection', (ws) => { console.log('Client connected'); ws.on('message', (msg) => console.log('Received:', msg.toString())); ws.send('Hello from server'); }); // Client const client = new WebSocketClient('ws://localhost:3000'); client.on('open', () => { console.log('Connected'); client.send('Hello from client'); }); client.on('message', (data) => console.log('Received:', data.toString()));
Debug
Known issues
gotchaThe library does not handle reconnection automatically.
fix
Implement custom reconnection logic or use a wrapper library.
affects: >=6.0.0
gotchaEvent listeners may cause memory leaks if not removed.
fix
Always remove event listeners when they are no longer needed.
affects: >=6.0.0
deprecatedThe old API with callback functions was removed in v6.
fix
Use the newer EventEmitter pattern with on()/off().
affects: <6.0.0
Errors
Common errors & fixes
TypeError: qiao_ws.WebSocketServer is not a constructor
Importing the library incorrectly as a default import or missing named export.
fix
Use import { WebSocketServer } from 'qiao-ws' instead of import qiaoWs from 'qiao-ws'.
Error: listen EADDRINUSE :::3000
Port 3000 is already in use by another process.
fix
Change the port number or kill the process using that port.
Upgrade
Version history
6.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources