Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda