Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

83
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!