M
M
MbIW2019-11-18 16:17:05
Node.js
MbIW, 2019-11-18 16:17:05

How to send authorization data to app on different port on NestJs via websockets?

there is a server application launched on the 3000th port, it authorizes/registers the user. And there is a client application on port 3001 that will send a login with a password via websockets

import { WebSocketGateway, SubscribeMessage } from '@nestjs/websockets';
import { Socket } from 'socket.io';

@WebSocketGateway(3000, {transports: ['websocket']})

export class AuthGateway {

  @SubscribeMessage('auth')
  handleEvent(client: Socket, auth: {username: "user2", password: "[email protected]#"}) {
    return auth;
  } 
}

when I run both applications, the client gives an error (Error: listen EADDRINUSE: address already in use :::3000), why is that? Or is it necessary to do this through the http module?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-11-18
@Xuxicheta

And there is a client application on port 3001

and then write
So on 3001 or 3000?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question