Multiple DB Connections are getting Created In MongoDb

I have to do real time changes in my site. I’m using Nest.js and server sent Events for real time changes.

Client Will call My SSE API passing some required information in query params and Authorization Header. What I’m doing in my SSE API is on change in mongoDB collection, will pass specific data user wise.

In my service I have set Watch on 2 collections and in SSE API doing operation ON CHANGE of mongo watch instance.

**ISSUE: ** Multiple DB connections are getting created when I check in Atlas. Example: Lets say User 1 changes some data, and User 2,3,4,5,6 are already on page and connected to Server sent events API so they are gonna receive real time change for this.

But I do have initialized/Open My change Stream Globally and Not in SSE API, also I do know every Collection Watch creates separate DB connection. But I have 2 collections to watch only so why it keeps creating collection on change.

Below is the code I have tried with


function(@Req() req): Observable<any> {
  const subject$ = new Subject();
  this.sseService.commonEventEmitter(req, subject$);
  return subject$.pipe(
    map((data: any) => ({ data, type: data.fetchTasks.event }))


export class ServerSentEventsService implements OnApplicationShutdown {
  //injected model and service here
) {}[],{fullDocument:'updateLookup'})

commonEventEmitter(req, subject$): void {
  this.collectionWatcher.on('change', (next: any) => {
   //Operations I have to do on change

onApplicationShutdown(signal: string) {
  console.log(`Application closes`);