ts-node .\src\main.ts
[Nest] 10052 - 2019-11-14 16:00:07 [NestFactory] Starting Nest application...
[Nest] 10052 - 2019-11-14 16:00:07 [InstanceLoader] AppModule dependencies initialized +30ms
[Nest] 10052 - 2019-11-14 16:00:07 [TerminalsAdapter] Creating with:{"path":"/terminals"} port:0
[Nest] 10052 - 2019-11-14 16:00:07 [TerminalsGateway] Server path:/terminals
[Nest] 10052 - 2019-11-14 16:00:07 [TerminalsTestGateway] Server path:/terminals
[Nest] 10052 - 2019-11-14 16:00:07 [RoutesResolver] AppController {/}: +19ms
[Nest] 10052 - 2019-11-14 16:00:07 [RouterExplorer] Mapped {/, GET} route +18ms
[Nest] 10052 - 2019-11-14 16:00:07 [NestApplication] Nest application successfully started +17ms
@WebSocketGateway({ path: '/terminals' })
export class TerminalsGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
private clientMap: Map<WebSocket, number>;
protected readonly logger = new Logger(TerminalsGateway.name);
constructor() {
this.clientMap = new Map<WebSocket, number>();
}
async afterInit(server: WebSocket.Server): Promise<void> {
this.logger.log(`Server path:${server.options.path}`);
}
@WebSocketServer()
server: WebSocket.Server;
async handleConnection(client: WebSocket): Promise<void> {
// A client has connected
client.send('Hello, the world\n');
this.clientMap.set(client, Date.now());
}
async handleDisconnect(client: WebSocket): Promise<void> {
this.clientMap.delete(client);
}
}
@WebSocketGateway({ path: '/terminals-test' })
export class TerminalsTestGateway
implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
private clientMap: Map<WebSocket, number>;
protected readonly logger = new Logger(TerminalsTestGateway.name);
constructor() {
this.clientMap = new Map<WebSocket, number>();
}
async afterInit(server: WebSocket.Server): Promise<void> {
this.logger.log(`Server path:${server.options.path}`);
}
@WebSocketServer()
server: WebSocket.Server;
async handleConnection(client: WebSocket): Promise<void> {
// A client has connected
client.send('Hello, the world\n');
this.clientMap.set(client, Date.now());
}
async handleDisconnect(client: WebSocket): Promise<void> {
this.clientMap.delete(client);
}
}
TerminalsGateway and TerminalsTestGateway show serve on different endpoint /terminals
, /terminals-test
respectively
Nest version: 6.9.0
For Tooling issues:
- Node version: 12.13
- Platform: Windows
i've got the same problem
Hello, this is still open for ws-adapter
on "@nestjs/websockets": "^6.11.3", "@nestjs/core": "^6.11.4",
right?
I think not only WsAdapter but also SocketIoAdapter leaks this feature.
@Menci Can't this be solved in Socket.io using the "namespace" feature?
@visurel Not everyone wants to use socket.io though.
Is there any update on this?
In the case that a minimum reproduction is still needed I've created one here with reproduction steps in the README
+1
Most helpful comment
@visurel Not everyone wants to use socket.io though.
Is there any update on this?