'Stickiness for 2 socket clients with a socket server

My application has two socket clients(one a windows service written in .Net and the other a ReactJS front end). These two are connected to a socket server, written in NestJS. The two clients interact with each other via the server over socket events. They never interact directly. Also, the windows client that runs on the host machine is always connected to a server instance. While the front end connects randomly to any instance. For the application to work, it is very necessary that windows client and front end client connect to the same server instance as it's only then that they could emit and listen to events. When they connect to different server instances, they are like two people connected to a separate WhatsApp group. How can I make both the clients connect to the same server instance?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source