title: NodeJS : Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
body: <p>Using Polling like below to check if the content of the file is changed then, other two functions are called  </p>
  
  <blockquote>
  <pre><code>var poll_max_date=AsyncPolling(function (end,err) {   if(err)   {
         console.error(err);   }   var stmp_node_id=fs.readFileSync(path.join(__dirname,'node_id'),"utf8"); 
     console.log("--------loaded node : "+stmp_node_id);  
     if(druid_stmp_node_id!=stmp_node_id)   {
           // MAX DATA CUT-OFF DRUID QUERY
           druid_exe.max_date_query_fire();
  
           // // DRUID QUERY FOR GLOBAL DATA
           druid_exe.global_druid_query_fire();
  
           druid_stmp_node_id=stmp_node_id;   }
  
       end(); }, 1800000).run();//30 mins
  </code></pre>
  </blockquote>
  
  <p>Its working fine for sometime, but then getting below error like after 4 - 5hours :</p>
  
  <blockquote>
    <p>events.js:167
          throw er; // Unhandled 'error' event
          ^</p>
    
    <p>Error: read ECONNRESET
        at TCP.onStreamRead (internal/stream_base_commons.js:111:27) Emitted 'error' event at:
        at emitErrorNT (internal/streams/destroy.js:82:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)</p>
  </blockquote>
  
  <p>tried using fs.watch to monitor the changes in the file instead of polling like below :</p>
  
  <blockquote>
    <p>let md5Previous = null; let fsWait = false;</p>
    
    <p>fs.watch(dataSourceLogFile, (event, filename) => {   if (filename) {</p>
  
  <pre><code>if (fsWait) return;
  fsWait = setTimeout(() =&gt; {
    fsWait = false;
  }, 1000);
  
  const md5Current = md5(fs.readFileSync(dataSourceLogFile));
  if (md5Current === md5Previous) {
    return;
  }
  
  md5Previous = md5Current;
  
  console.log(`${filename} file Changed`);
  
  // MAX DATA CUT-OFF DRUID QUERY
  druid_exe.max_date_query_fire();
  // DRUID QUERY FOR GLOBAL DATA
  druid_exe.global_druid_query_fire();   } });
  </code></pre>
  </blockquote>
  
  <p>Its is also working fine for sometime, but then getting same error like after 4 - 5hours :</p>
  
  <blockquote>
    <p>events.js:167 throw er; // Unhandled 'error' event ^</p>
    
    <p>Error: read ECONNRESET at TCP.onStreamRead
    (internal/stream_base_commons.js:111:27) Emitted 'error' event at: at
    emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT
    (internal/streams/destroy.js:50:3)</p>
  </blockquote>
  
  <p>But when run in Local Machine, its working fine. the error occurs only when run in remote Linux Machine.</p>
  
  <p>somebody can help me how I can fix that problem?</p>