Skip to content

WebSocket Gateway - doesn't work with ExpressAdapter #2355

Closed
@adrianpiesiak

Description

@adrianpiesiak

Bug Report

Current behavior

WebSocket Gateway is not working properly when Nest application is created by using ExpressAdapter.

It seems that the gateway is not linked properly to the http service - client gets 404 upon connection, gateway itself seems to be initiated (OnGatewayInit is executed with meaningful result).

Input Code

I've created minimal code to reproduce.
In the main.ts there are two bootstrap method implementations - one works, second one doesn't.

There is client.js file to simulate the client. Simply run it with node client.js - it should produce console logs in both server (when socket is properly connected) and in client (upon connection error).

https://github.com/adrianpiesiak/NestJs-socket-bug

Expected behavior

The WebSocketGateway should work in both bootstrapping methods

Environment

Node: 10.15.2
@nestjs/core@6.3.1
@nestjs/common@6.3.1
@nestjs/platform-socket.io@6.3.1
@nestjs/platform-express@6.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions