Registry / messaging / socket-redis

socket-redis

JSON →
library3.3.0jsnpmunverified

socket-redis is a WebSocket pub/sub server and client that exposes an API over Redis, allowing applications to use WebSocket functionality via a Redis client. Version 3.3.0 is current; the package is stable with low release cadence (last release Jan 2023). It bridges SockJS clients to Redis channels, supporting multi-core via child processes. Key differentiator: no direct WebSocket library dependency—uses Redis as the message bus, enabling decoupled architectures.

npm install socket-redis
INSTALL
IMPORT
SIG · SOCKET-REDIS
S
socket-redis
messagingjavascriptv3.3.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.

Server
import { Server } from 'socket-redis'
const Server = require('socket-redis').Server
Package is ESM-only since v3. CommonJS require will fail.
Client
import { Client } from 'socket-redis'
const Client = require('socket-redis').Client
Default export in v2, named export in v3.
RedisMessenger
import { RedisMessenger } from 'socket-redis'
const { RedisMessenger } = require('socket-redis')
Named export, only available in v3+.

Starts a socket-redis server listening on port 8090, connecting to Redis at localhost:6379.

import { Server } from 'socket-redis'; const server = new Server({ redisHost: process.env.REDIS_HOST ?? 'localhost', redisPort: Number(process.env.REDIS_PORT ?? 6379), socketPorts: [8090], }); server.on('error', (err) => console.error(err)); server.start().then(() => console.log('Socket server running'));
Debug
Known issues
breakingsocket-redis v3 removed CommonJS support. require() will throw ERR_REQUIRE_ESM.
fix
Use import syntax. If using TypeScript, set moduleResolution to node16 or nodenext.
affects: >=3.0.0
gotchaThe server uses SockJS, not native WebSocket. Clients must use sockjs-client library.
fix
Ensure client connects via SockJS protocol (e.g., new SockJS(url)) instead of new WebSocket(url).
affects: >=1.0.0
gotchaRedis channels 'socket-redis-up' and 'socket-redis-down' are hardcoded. Cannot be configured.
fix
Use a Redis proxy or modify source if custom channel names are required.
affects: >=1.0.0
deprecatedThe HTTP status endpoint on port 8085 is deprecated since v3.2 and will be removed in v4.
fix
Use Prometheus /metrics endpoint instead.
affects: >=3.2.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS require() on socket-redis v3+ which is ESM-only.
fix
Switch to import syntax: import { Server } from 'socket-redis'
TypeError: (intermediate value).on is not a function
Calling .on() on a promise instead of the server instance. Start().on() is incorrect.
fix
Correct: await server.start(); server.on('error', ...);
Error: listen EADDRINUSE :::8090
Default port 8090 already in use.
fix
Specify a different port via --socket-ports or socketPorts option.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies
redisrequiredUsed for pub/sub messaging between server and clients
sockjsrequiredWebSocket emulation library for browser compatibility
sockjs-clientoptionalClient-side SockJS library
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
socket-redis — npm install socket-redis · libregistry