Questions tagged [nestjs-gateways]
42 questions
1
vote
0 answers
NestJS socket gateway with mongoose watch repository method -> close event is being called immediately with no error and no changes are being observed
I created a NotificationGateway in Nestjs and injected the notificationRepository.
afterInit method is being called and the changeStream.on('close') event is being thrown with no error.
When adding a new notification document the 'change' event is…

Ron Barak
- 11
- 3
1
vote
1 answer
Custom decorator not being invoked on socket message handler (NestJS, SocketIO)
In app.gateway.ts, I have the following event handler:
@SubscribeMessage('event')
async handleRefreshCheck(
@SocketContext() ctx: SocketContextDTO,
@ConnectedSocket() socket: TSocket,
) {
this.logger.log({
…

vxm5091
- 153
- 7
1
vote
0 answers
NestJS GraphQL inconsistent autoSchemaFile and service sql
I'm using nestJS with ApolloFederationDriver. I also add some prefix with transformSchema option. The issue is that in sdl I can't see that prefix, but in the autoSchemaFile he is. It is a problem, because I can't create connection between this…

Евгений Богданов
- 11
- 2
1
vote
1 answer
NestJS tcp microservice load balance
I have a nestjs app as follows:
Gateway - HTTP
Microservice1 - TCP (ms1)
Microservice2 - TCP (ms2)
Gateway calling ms1 and ms2.
ms1 and ms2 are the same duplicated microservice.
I would like to load the balance between ms1 and ms2.
How do…

Gilad
- 11
- 3
1
vote
0 answers
UseFilters NestJS doesn't work when RcpException
I'm trying to filter RcpException (from RabbitMQ if it's matter)
gateway.ts:
@Get('test-exception')
@HttpCode(HttpStatus.OK)
@UseFilters(RpcExceptionFilter)
async testException() {
try {
return await…

utf_8
- 105
- 11
1
vote
2 answers
fail to consume kafka events with nestjs
I wanted to consume Kafka messages and thus I've invoked the emit() message first which successfully stored a message in Kafka.
I can see that by running the batch file: bin/windows/kafka-console-consumer.bat --topic signals --from-beginning…

feder
- 1,849
- 2
- 25
- 43
1
vote
0 answers
Inject service into gateway - NestJS
Am completely new to nestjs and trying to inject a service into a gateway. Not able to get it to work. Following is the code,
#notification.gateway.ts
@WebSocketGateway()
export class NotificationsGateway implements OnGatewayConnection {
…

user1832715
- 11
- 3
1
vote
1 answer
NestJs Socket io adapter: Server does not add CORS headers to handshake's response if allowFunction is called with false. Bug or misconfiguration?
authenticated-socket-io.adapter.ts
export class AuthenticatedSocketIoAdapter extends IoAdapter {
private readonly authService: AuthService;
constructor(private app: INestApplicationContext) {
super(app);
this.authService =…

M. C. Cristian
- 21
- 5
1
vote
0 answers
NestJS Gateways: path with slugs
I am trying to create a websockets gateway in NestJS that responds to multiple paths.
This is a requirement as what I am trying to build would replace an existing system.
I am using WsAdapter as the underlying adapter for this.
The websockets paths…

Manny
- 783
- 1
- 9
- 29
1
vote
1 answer
How to get repository in NestJS Interceptor
I had created on Interceptor in the module. I want to get repository [LocumRepository] in the Interceptor and put some processing after the call.
Following is my Intercepter class:
import { CallHandler, ExecutionContext, Injectable, NestInterceptor…

Hassan Ali Shahzad
- 2,439
- 29
- 32
1
vote
1 answer
How should be the schema on relations between microservices
I'm using NestJS + Prisma + Apollo Federation.
On microservice A is the definition of user, on microservice B is defined posts.
The relation is 1 - N, a user can have N posts.
In Prisma, datamodel of Post is defined with a String for user, since…

arceliver
- 336
- 1
- 11
1
vote
1 answer
Use Interceptor inside another Interceptor In nestjs
I am creating a interceptor Inside that I want to use FileInterceptor but I am getting error Declaration Expected after FileInterceptor
import { CallHandler, ExecutionContext, Injectable, NestInterceptor, UseInterceptors } from…

Akhilesh Jha
- 23
- 3
- 9
1
vote
1 answer
Not able to call Service inside WebSocket listener in Nestjs
I have implemented WebSockets in Nestjs using below method and one of the requirement is that I need to update the db once I receive any message from websocket server.
In order to do that I have done the below code but getting error like this:
But…

Rajkumar
- 440
- 7
- 31
0
votes
0 answers
NestJs: how to get sockets connected to one namespace in another namespace
I have two nestjs gateways handling events emitted from the client. One for the 'admin' namespace and one for the 'chat' namespace. When handling one of the events on the 'admin' gateway, i would like to retrieve all of sockets that are connected to…

rtovsak
- 1
0
votes
1 answer
property signin, sign up does not exist on type AuthService
auth.controller file
`import { Test, TestingModule } from '@nestjs/testing';
import { AuthController } from './auth.controller';
describe('AuthController', () => {
let controller: AuthController;
beforeEach(async () => {
const module:…

umair
- 9
- 1