{"id":46191,"library":"redis-ws-discovery","title":"Redis WS Discovery","description":"Redis WS Discovery (v0.2.0) enables WebSocket servers and clients to discover each other via Redis pub/sub without a central registry. Each server announces its identity (e.g., host, port) to a Redis channel, and clients (or other servers) listen for announcements to build a live list of available peers. Built on ioredis (^5.4.1), shipped with TypeScript definitions, requires Node >=20. Lightweight alternative to etcd or Consul for WebSocket topologies in Redis-heavy stacks. Released under new BSD license.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/arusakov/redis-ws-discovery","tags":["javascript","typescript"],"install":[{"cmd":"npm install redis-ws-discovery","lang":"bash","label":"npm"},{"cmd":"yarn add redis-ws-discovery","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-ws-discovery","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Redis client library for pub/sub and data operations","package":"ioredis","optional":false}],"imports":[{"note":"TypeScript-defined class for server-side discovery registration","wrong":"const { WsDiscoveryServer } = require('redis-ws-discovery')","symbol":"WsDiscoveryServer","correct":"import { WsDiscoveryServer } from 'redis-ws-discovery'"},{"note":"Client for listening to server announcements","wrong":"const WsDiscoveryClient = require('redis-ws-discovery').WsDiscoveryClient","symbol":"WsDiscoveryClient","correct":"import { WsDiscoveryClient } from 'redis-ws-discovery'"},{"note":"Factory function returning both server and client instances","wrong":"","symbol":"createDiscovery","correct":"import { createDiscovery } from 'redis-ws-discovery'"}],"quickstart":{"code":"import Redis from 'ioredis';\nimport { WsDiscoveryServer, WsDiscoveryClient } from 'redis-ws-discovery';\n\nconst redis = new Redis({ host: 'localhost', port: 6379 });\n\n// Server announces itself as 'ws://localhost:3000'\nconst server = new WsDiscoveryServer(redis, {\n  channel: 'ws:discovery',\n  identity: { url: 'ws://localhost:3000' },\n  ttl: 30000\n});\nserver.start();\n\n// Client listens for announcements\nconst client = new WsDiscoveryClient(redis, { channel: 'ws:discovery' });\nclient.on('peer', (peer) => {\n  console.log('Discovered peer:', peer.url);\n});\nclient.start();\n\n// Stop after 10 seconds\nsetTimeout(() => {\n  server.stop();\n  client.stop();\n  redis.quit();\n}, 10000);","lang":"typescript","description":"Shows basic server discovery registration and client discovery listening via Redis pub/sub."},"warnings":[{"fix":"Ensure all instances use the same Redis connection and channel string.","message":"Both server and client require a shared Redis instance and same channel name to discover each other.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to v20+ or use an earlier version of the package if available.","message":"Requires Node >=20.0.0, incompatible with older Node.js versions.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Install ioredis@^5.4.1 as a dependency.","message":"ioredis peer dependency is required; using other Redis clients (e.g., node-redis) will cause runtime errors.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Include a 'url' property in the identity object passed to WsDiscoveryServer.","message":"Identity object must contain a 'url' field; any custom fields may be optional but the package expects at least this.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Configure ttl in options to control re-announcement frequency.","message":"TTL (time-to-live) for server announcements must be set explicitly; default is 30000ms.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Manually fetch active servers after client start using a separate mechanism if needed.","message":"Client emits 'peer' event only when a new server appears or updates; it does not emit the initial list on connect.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Optionally implement a manual removal via Redis client before stopping the server.","message":"Stopping server does not clear its announcement from Redis peers immediately; they will be removed after TTL expires.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'20':62 '5.4.1':55 'altern':64 'announc':26,43 'avail':50 'bsd':80 'build':45 'built':52 'central':22 'channel':35 'client':12,37 'consul':68 'definit':59 'discov':14 'discoveri':3,6 'e.g':29 'enabl':8 'etcd':66 'heavi':75 'host':30 'ident':28 'ioredi':54 'javascript':82 'licens':81 'lightweight':63 'list':48 'listen':41 'live':47 'new':79 'node':61 'peer':51 'port':31 'pub/sub':19 'redi':1,4,18,34,74 'redis-heavi':73 'registri':23 'releas':77 'requir':60 'server':10,25,40 'ship':56 'stack':76 'topolog':71 'typescript':58,83 'v0.2.0':7 'via':17 'websocket':9,70 'without':20 'ws':2,5","created_at":"2026-06-07T12:58:44.166784+00:00","updated_at":"2026-06-07T12:58:44.166784+00:00","problems":[{"fix":"npm install ioredis@^5.4.1","cause":"Missing peer dependency ioredis","error":"Error: Cannot find module 'ioredis'"},{"fix":"Install ioredis and use it as the Redis client","cause":"Passed a Redis client that does not support pub/sub (e.g., node-redis instead of ioredis)","error":"TypeError: redis.subscribe is not a function"},{"fix":"Use import syntax or enable ESM in your project","cause":"Using CommonJS require() on an ESM-only package (since v0.2.0 may be ESM)","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Set a valid channel string in options","cause":"Channel name was not provided or was empty","error":"TypeError: Invalid channel: must be a non-empty string"},{"fix":"Add 'url' property to the identity object passed to WsDiscoveryServer","cause":"Identity object missing 'url' field","error":"Error: identity.url is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/arusakov/redis-ws-discovery#readme","github":"https://github.com/arusakov/redis-ws-discovery","docs":null,"changelog":null,"pypi":null,"npm":"redis-ws-discovery","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}