title: nestjs sockets connected and disconnected
body: <p>I have sockets problem with Nestjs, in every second it writes connected and disconnected, searched some several same questions on Stackoverflow, also on Youtube lessons but did not help.. will be happy if someone helps..</p>
  <p>this is log</p>
  <pre><code>[Nest] 12036   - 04/02/2021, 9:18:03 PM   [AppGateWay] lient disconnected jRscMMVD0squB05iAABX
  [Nest] 12036   - 04/02/2021, 9:18:03 PM   [AppGateWay] lient connecter fIlNEX9iuFZczryIAABt
  [Nest] 12036   - 04/02/2021, 9:18:03 PM   [AppGateWay] lient connecter uZNRYlyQ-MbAawJMAABu
  [Nest] 12036   - 04/02/2021, 9:18:06 PM   [AppGateWay] lient disconnected DPvlifohhyihQCWsAABY
  [Nest] 12036   - 04/02/2021, 9:18:06 PM   [AppGateWay] lient connecter k3uyxN-fc3GrGsdDAABv
  [Nest] 12036   - 04/02/2021, 9:18:07 PM   [AppGateWay] lient disconnected x8fuIwTgLKcOrZzvAABZ
  [Nest] 12036   - 04/02/2021, 9:18:07 PM   [AppGateWay] lient connecter Y2KR6mRUf70lidA_AABw
  [Nest] 12036   - 04/02/2021, 9:18:08 PM   [AppGateWay] lient disconnected 1SIGUFCZthvnkLBoAABa
  [Nest] 12036   - 04/02/2021, 9:18:08 PM   [AppGateWay] lient disconnected Zy9txh5pIosNNxHTAABb
  [Nest] 12036   - 04/02/2021, 9:18:08 PM   [AppGateWay] lient connecter LB4h3oOjP0aKjjcBAABx
  [Nest] 12036   - 04/02/2021, 9:18:08 PM   [AppGateWay] lient connecter VDoVyVgXE9zQWrkGAABy
  [Nest] 12036   - 04/02/2021, 9:18:11 PM   [AppGateWay] lient disconnected DGk_RFIFQFw-h25DAABc
  </code></pre>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;nestjs-task-management&quot;,
    &quot;version&quot;: &quot;0.0.1&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;author&quot;: &quot;&quot;,
    &quot;private&quot;: true,
    &quot;license&quot;: &quot;UNLICENSED&quot;,
    &quot;scripts&quot;: {
      &quot;prebuild&quot;: &quot;rimraf dist&quot;,
      &quot;build&quot;: &quot;nest build&quot;,
      &quot;format&quot;: &quot;prettier --write \&quot;src/**/*.ts\&quot; \&quot;test/**/*.ts\&quot;&quot;,
      &quot;start&quot;: &quot;ts-node -r tsconfig-paths/register src/main.ts&quot;,
      &quot;start:dev&quot;: &quot;nodemon&quot;,
      &quot;start:debug&quot;: &quot;nodemon --config nodemon-debug.json&quot;,
      &quot;start:prod&quot;: &quot;node dist/main&quot;,
      &quot;lint&quot;: &quot;eslint \&quot;{src,apps,libs,test}/**/*.ts\&quot; --fix&quot;,
      &quot;test&quot;: &quot;jest&quot;,
      &quot;test:watch&quot;: &quot;jest --watch&quot;,
      &quot;test:cov&quot;: &quot;jest --coverage&quot;,
      &quot;test:debug&quot;: &quot;node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand&quot;,
      &quot;test:e2e&quot;: &quot;jest --config ./test/jest-e2e.json&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@nestjs/common&quot;: &quot;^7.0.0&quot;,
      &quot;@nestjs/core&quot;: &quot;^7.0.0&quot;,
      &quot;@nestjs/jwt&quot;: &quot;^7.1.0&quot;,
      &quot;@nestjs/passport&quot;: &quot;^7.1.0&quot;,
      &quot;@nestjs/platform-express&quot;: &quot;^7.3.1&quot;,
      &quot;@nestjs/platform-socket.io&quot;: &quot;^15.6.15&quot;,
      &quot;@nestjs/serve-static&quot;: &quot;^2.1.4&quot;,
      &quot;@nestjs/typeorm&quot;: &quot;^7.1.0&quot;,
      &quot;@nestjs/websockets&quot;: &quot;^7.6.15&quot;,
      &quot;@types/sharp&quot;: &quot;^0.27.1&quot;,
      &quot;class-transformer&quot;: &quot;^0.2.3&quot;,
      &quot;class-validator&quot;: &quot;^0.12.2&quot;,
      &quot;config&quot;: &quot;^3.3.1&quot;,
      &quot;g&quot;: &quot;^2.0.1&quot;,
      &quot;global&quot;: &quot;^4.4.0&quot;,
      &quot;multer&quot;: &quot;^1.4.2&quot;,
      &quot;nodemon&quot;: &quot;^2.0.3&quot;,
      &quot;passport&quot;: &quot;^0.4.1&quot;,
      &quot;passport-jwt&quot;: &quot;^4.0.0&quot;,
      &quot;pg&quot;: &quot;^8.2.1&quot;,
      &quot;reflect-metadata&quot;: &quot;^0.1.13&quot;,
      &quot;rimraf&quot;: &quot;^3.0.2&quot;,
      &quot;rxjs&quot;: &quot;^6.5.4&quot;,
      &quot;sharp&quot;: &quot;^0.26.2&quot;,
      &quot;typeorm&quot;: &quot;^0.2.25&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@nestjs/cli&quot;: &quot;^7.0.0&quot;,
      &quot;@nestjs/schematics&quot;: &quot;^7.0.0&quot;,
      &quot;@nestjs/swagger&quot;: &quot;^4.6.0&quot;,
      &quot;@nestjs/testing&quot;: &quot;^7.0.0&quot;,
      &quot;@types/express&quot;: &quot;^4.17.7&quot;,
      &quot;@types/jest&quot;: &quot;25.1.4&quot;,
      &quot;@types/node&quot;: &quot;^13.9.1&quot;,
      &quot;@types/socket.io&quot;: &quot;^2.1.13&quot;,
      &quot;@types/supertest&quot;: &quot;^2.0.8&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^2.23.0&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^2.23.0&quot;,
      &quot;bcrypt&quot;: &quot;^5.0.0&quot;,
      &quot;cross-env&quot;: &quot;^7.0.2&quot;,
      &quot;eslint&quot;: &quot;^6.8.0&quot;,
      &quot;eslint-config-prettier&quot;: &quot;^6.10.0&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.20.1&quot;,
      &quot;jest&quot;: &quot;^25.1.0&quot;,
      &quot;prettier&quot;: &quot;^1.19.1&quot;,
      &quot;supertest&quot;: &quot;^4.0.2&quot;,
      &quot;swagger-ui-express&quot;: &quot;^4.1.4&quot;,
      &quot;ts-jest&quot;: &quot;25.2.1&quot;,
      &quot;ts-loader&quot;: &quot;^6.2.1&quot;,
      &quot;ts-node&quot;: &quot;^8.6.2&quot;,
      &quot;tsconfig-paths&quot;: &quot;^3.9.0&quot;,
      &quot;typescript&quot;: &quot;^3.8.3&quot;
    },
    &quot;jest&quot;: {
      &quot;moduleFileExtensions&quot;: [
        &quot;js&quot;,
        &quot;json&quot;,
        &quot;ts&quot;
      ],
      &quot;rootDir&quot;: &quot;src&quot;,
      &quot;testRegex&quot;: &quot;.spec.ts$&quot;,
      &quot;transform&quot;: {
        &quot;^.+\\.(t|j)s$&quot;: &quot;ts-jest&quot;
      },
      &quot;coverageDirectory&quot;: &quot;../coverage&quot;,
      &quot;testEnvironment&quot;: &quot;node&quot;
    }
  }
  </code></pre>
  <p>app.gateway.ts</p>
  <pre><code>import { Socket,Server } from 'socket.io';
  import { Logger } from '@nestjs/common';
  import { SubscribeMessage, WebSocketGateway, OnGatewayInit, OnGatewayConnection } from '@nestjs/websockets';
  
  @WebSocketGateway()
  export class AppGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayConnection{
    private logger: Logger = new Logger(&quot;AppGateWay&quot;);
    
    afterInit(server: Server){
      this.logger.log('Initialized')
    }
  
    handleConnection(client: Socket){
      this.logger.log(`lient connecter ${client.id}`)
    }
    handleDisconnect(client: Socket){
      this.logger.log(`lient disconnected ${client.id}`)
    }
  
    @SubscribeMessage('message')
    handleMessage(client: any, payload: any): string {
      return 'Hello world!';
    }
  }
  </code></pre>
  <p>I have tried too many things but no result.... may be someone knows what to do? may be there is problem with versions as with another people but with which library or with which version... :|</p>