I have a web app that uses a WebSocket client to connect to a single WebSocket server.
How can I have this WebSocket client connect to another WebSocket server at the same time?
I need to receive data from two different sources (2 different WebSocket servers).
ws = new WebSocket(url 1, url 2);
2
Answers
You can’t. A
WebSocket
object can connect to only 1 server at a time. For what you want, you will need to create multipleWebSocket
objects, one for each server.