A WebSocket client library for connecting to sockjs-broker servers. Version 1.2.12 provides a client base for establishing WebSocket connections via the SockJS protocol, supporting reconnection, event handling, and message exchange. Released with low update frequency, it is intended for use with the sockjs-broker server-side component. Key differentiators include lightweight implementation and compatibility with SockJS fallback transports for browser environments, but limited documentation and ecosystem support compared to alternatives like native WebSocket or Socket.IO.
npm install sockjs-broker-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a SockJSBrokerClient connecting to a broker, subscribes to a channel, and logs messages.
Use 'token' instead of 'authToken' in options object.
Use import { SockJSBrokerClient } from 'sockjs-broker-client'.Install 'ws' and assign global.WebSocket = require('ws'); or use Node >=18 with native WebSocket.Set transports option to ['websocket'] to force WebSocket only if server supports it.
Ensure server sends Access-Control-Allow-Origin and Access-Control-Allow-Credentials headers.
Use const { SockJSBrokerClient } = require('sockjs-broker-client');Start sockjs-broker server on the expected host:port before client connection.
Install 'ws' and set global.WebSocket = require('ws');Ensure client is connected via 'open' event before calling send.