title: Error: read ECONNRESET at TLSWrap.onStreamRead when closing the browser/tabs
body: <p>im writing my first chat app in nodejs , my app basically keeps track of online users and put them in the rooms to chat via webrtc ...im using pm2 to run the chat server</p>
  <p>so i noticed sometimes when i close browser tabs my app will crash and pm2 will reload the server so i checked the log and saw this error</p>
  <pre><code>0|chat  | Error: read ECONNRESET
  0|chat  |     at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20) {
  0|chat  |   errno: -104,
  0|chat  |   code: 'ECONNRESET',
  0|chat  |   syscall: 'read'
  0|chat  | }
  </code></pre>
  <p>here is the error when runing withouth pm2</p>
  <pre><code>node:events:368
        throw er; // Unhandled 'error' event
        ^
  
  Error: read ECONNRESET
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20)
  Emitted 'error' event on TLSSocket instance at:
      at emitErrorNT (node:internal/streams/destroy:157:8)
      at emitErrorCloseNT (node:internal/streams/destroy:122:3)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    errno: -104,
    code: 'ECONNRESET',
    syscall: 'read'
  }
  </code></pre>
  <p>to make sure it's not my code causing this error i removed all the codes in my app and just put 2 simple function to listen to online(called by online client via socket.io) and disconnect(called automatically by user disconnect ) events ... and sure enough after closing and opening some tabs it happen again here is simplified version of my code</p>
  <p>im using <code>Express.io</code> which is a combination of Express and Socket.io</p>
  <pre><code>const  env = require('dotenv').config({ path: '.env' })
  const https = require('https');
  const fs = require('fs');
  
  app = require('express.io')();
  
  var options = {
      key: fs.readFileSync( env.parsed.SSL_KEY),
      cert: fs.readFileSync(env.parsed.SSL_CERT)
  };
  app.https(options).io();
  console.log('|-&gt; protocol : https ');
  
  
  
  app.io.route('online' , function (req){
      console.log(`| online socket -&gt; ${req.socket.id}`);
  })
  
  
  app.io.route('disconnect', function(req) {
      console.log(`|-&gt;****************** disconnect : ${req.socket.id}`);
  });
  
  var PORT = env.parsed.PORT  || 8080
  console.log(`|-&gt; listining to port ${PORT} `);
  app.listen(PORT );
  </code></pre>
  <p>i've searched online and know why it's happening (i think) but i dont have any data communication in this code it  .... i've no idea how to handle this and appreciate any help</p>
  <p>here is the complete log you can see it happening after closing some tabs</p>
  <p><a href="https://i.stack.imgur.com/R1lS3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R1lS3.png" alt="enter image description here" /></a></p>
  <pre><code>/root/.pm2/logs/chat-out.log last 15 lines:
  0|chat     | |-&gt; protocol : https
  0|chat     | |-&gt; listining to port 8080
  
  /root/.pm2/logs/chat-error.log last 15 lines:
  0|chat     | (node:19821) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
  0|chat     | (Use `node --trace-deprecation ...` to show where the warning was created)
  
  0|chat  | | online socket -&gt; Z2z7m6D9OXKPGRVhbz4R
  0|chat  | |-&gt;****************** disconnect : H_1-d7sIm2oIvxzzbz4Q
  0|chat  | | online socket -&gt; JrnLWbqN4luBtYg4bz4S
  0|chat  | | online socket -&gt; ZSY1wIywMEdmUcALbz4T
  0|chat  | | online socket -&gt; ugSg08DksJ73ld1Rbz4U
  0|chat  | |-&gt;****************** disconnect : ugSg08DksJ73ld1Rbz4U
  0|chat  | |-&gt;****************** disconnect : ZSY1wIywMEdmUcALbz4T
  0|chat  | Error: read ECONNRESET
  0|chat  |     at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20) {
  0|chat  |   errno: -104,
  0|chat  |   code: 'ECONNRESET',
  0|chat  |   syscall: 'read'
  0|chat  | }
  PM2     | App [chat:0] exited with code [1] via signal [SIGINT]
  PM2     | App [chat:0] starting in -fork mode-
  PM2     | App [chat:0] online
  0|chat  | |-&gt; protocol : https
  0|chat  | |-&gt; listining to port 8080
  0|chat  | (node:19864) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
  0|chat  | (Use `node --trace-deprecation ...` to show where the warning was created)
  </code></pre>