Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJS multiple WebSocketGateway

Is it possible to run one NestJS WebSocketGateway several times with different parameters? Maybe possible to use microservices for this?

like image 335
Morbo Avatar asked May 30 '26 02:05

Morbo


1 Answers

Yes, it is possible to create as much WebSocketGateway as you want. All you need is to register your gateways in providers property of your @Module. Gateways with same port will use only 1 socket.io server instance. When you create gateway with another port, NestJS will create one more server instance and so on.

like image 109
Dilame Nickolson Avatar answered Jun 02 '26 20:06

Dilame Nickolson