moonpyk / node-ntp-client

Pure Javascript implementation of the NTP Client Protocol
MIT License
58 stars 42 forks source link

Closing closed connection ntp-client.js:80:24 #7

Open gfduszynski opened 8 years ago

gfduszynski commented 8 years ago

If connection gets closed due to external event error is experienced after attempt to send 'ntpData'.

Connection should be only closed if open :)

Details:

dgram.js:420
    throw new Error('Not running'); // error message from dgram_legacy.js
          ^
Error: Not running
    at Socket._healthCheck (dgram.js:420:11)
    at Socket.close (dgram.js:327:8)
    at /opt/cos-medico/new/node_modules/ntp-client/lib/ntp-client.js:80:24
    at dgram.js:297:21
    at asyncCallback (dns.js:68:16)
    at Object.onanswer [as oncomplete] (dns.js:124:7)
jfriend00 commented 8 years ago

I'm having this issue too if there are networking issues at the time I try to fetch the ntp time. It doesn't seem like the code here should throw. It should just return an error on the normal error callbacks.