From 63fa018851b45ad6996e1f17cc8e848cc738d0f3 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Tue, 6 May 2025 16:44:27 +0330 Subject: [PATCH] add online/offline api --- src/socket/socket.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/socket/socket.service.ts b/src/socket/socket.service.ts index 0518f2a..d6c646a 100644 --- a/src/socket/socket.service.ts +++ b/src/socket/socket.service.ts @@ -1,7 +1,7 @@ import { HttpService } from '@nestjs/axios'; import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { firstValueFrom } from 'rxjs'; +import { firstValueFrom, retry } from 'rxjs'; import { Socket } from 'socket.io'; import { Repository } from 'typeorm'; import { ClientConnectionDto } from './dto/clientConnection.dto'; @@ -30,7 +30,9 @@ export class SocketService { if (endpoint) { const url = `${process.env.SERVICE_URL}${endpoint}?telephone_id=${client.client_id}`; try { - await firstValueFrom(this.httpService.get(url)); + await firstValueFrom( + this.httpService.get(url, { timeout: 3000 }).pipe(retry(3)), + ); } catch (error) { this.logger.error( `❌ Failed to notify ${data.event} for client ${client.client_id}:`,