From 7a29b9064ac4ee5abf01be662211b5dd54892051 Mon Sep 17 00:00:00 2001 From: Rory Oldershaw Date: Thu, 5 Dec 2013 23:50:23 +0000 Subject: [PATCH] Handle socket errors --- lib/ping_services/smtp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ping_services/smtp.js b/lib/ping_services/smtp.js index 152260f0..ef163a9b 100644 --- a/lib/ping_services/smtp.js +++ b/lib/ping_services/smtp.js @@ -9,7 +9,10 @@ function ping (service, callback){ socket.on("data", function (c) { socket.end("bye!"); }); - + + socket.on("error", function () { + callback("Could not open socket", null, null, null); + }); socket.on("end", function () { var timeDiff = (new Date() - startTime); callback(null, null, null, timeDiff);