Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

85
Vistas
Connect to multiple websocket clients and use single onmessage stream

I am currently working on an application which requires me to connect to multiple different websocket sources (40 to be exact).

My goal or aim would be to have all sources stream their data through one pooled 'onMessage' stream and have them tagged per-source so I can identify which source emitted what event and parse them accordingly.

const tags = [
  { id : "stream1", url : "ws//example1"},
  { id : "stream2", url : "ws//example2"},
  { id : "stream3", url : "ws//example3"},
]

// Current implementation (bad)
tags.every(e => ws.connect(e.url))

Ideally, if a message comes in I would like to see the emitter source (tag) and the event being emitted. I'm not sure if this is possible but I feel like it just has to be.

The only other alternative seems to be creating 40 individual websocket client connections, which feels like bad practice and also generates the maxListenerExceeded warning, which is to be expected.

Any suggestions or useful packages I might have overlooked ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda