title: How to solve: premature close at onclosenexttick in Node.js Server?
body: <p>How to solve this error, I am running my Node.js with AWS IoT then it at times shows this error:</p>
  
  <pre><code>      throw er; // Unhandled 'error' event
        ^
  
  Error: How  (/home/ec2-user/work/nodejs_27_01/node_modules/end-of-stream/index.js:54:                                                                                                     86)
      at processTicksAndRejections (internal/process/task_queues.js:79:11)
  Emitted 'error' event on DeviceClient instance at:
      at MqttClient.&lt;anonymous&gt; (/home/ec2-user/work/nodejs_27_01/node_modules/aws-iot-device-sdk/                                                                                                     device/index.js:772:15)
      at MqttClient.emit (events.js:333:22)
      at MqttClient.EventEmitter.emit (domain.js:485:12)
      at TLSSocket.f (/home/ec2-user/work/nodejs_27_01/node_modules/once/once.js:25:25)
      at onclosenexttick (/home/ec2-user/work/nodejs_27_01/node_modules/end-of-stream/index.js:54:                                                                                                     73)
  
  </code></pre>