Registry / messaging / sockjs-client-ws

sockjs-client-ws

JSON →
library0.1.0jsnpmunverified

A Node.js client for SockJS that only supports the WebSocket transport. Version 0.1.0, released in early development stage. Differentiates from other SockJS clients (e.g., sockjs-client for browsers) by focusing solely on WebSocket transport for Node.js environments, making it lightweight but non-compliant with SockJS protocol fallbacks. Not recommended for production; consider using the full-featured sockjs-client package for browser/Node compatibility.

npm install sockjs-client-ws
INSTALL
IMPORT
SIG · SOCKJS-CLIENT-WS
S
sockjs-client-ws
messagingjavascriptv0.1.0
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.

sockjs-client-ws
var sjsc = require('sockjs-client-ws');
import sjsc from 'sockjs-client-ws';
ESM import not supported; use CommonJS require.
create
var client = sjsc.create(url);
var client = new sjsc(url);
Factory function, not a constructor. Use sjsc.create()
client.write
client.write(data);
client.send(data);
Method is write, not send.

Creates a SockJS WebSocket client, listens for connection, data, and error events, and sends a message.

var sjsc = require('sockjs-client-ws'); var client = sjsc.create("http://localhost:9999/echo"); client.on('connection', function () { console.log('Connected'); client.write("Hello SockJS!"); }); client.on('data', function (msg) { console.log('Received:', msg); }); client.on('error', function (e) { console.error('Error:', e); });
Debug
Known issues
gotchaOnly WebSocket transport is supported; SockJS fallbacks (XHR, EventSource) are not implemented.
fix
Use sockjs-client (full-featured) for browser fallback support.
affects: 0.1.0
gotchaThe library does not auto-reconnect on connection loss.
fix
Implement manual reconnection logic or use a more robust client.
affects: 0.1.0
deprecatedPackage is not actively maintained and may have unresolved bugs.
fix
Consider using ws or sockjs-client packages instead.
affects: 0.1.0
Errors
Common errors & fixes
ReferenceError: sjsc is not defined
Using the variable before requiring the module.
fix
Ensure require('sockjs-client-ws') is called and assigned.
TypeError: sjsc.create is not a function
Incorrect import or using the wrong variable.
fix
Verify require returns an object with create method.
Error: connect ECONNREFUSED
SockJS server not running or wrong URL.
fix
Ensure server is running and URL is correct (e.g., ws:// or http://).
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
sockjs-client-ws — npm install sockjs-client-ws · libregistry