From 74008bc7deac7b8b1775fb6c1f7db5ab0317d7bd Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Fri, 29 May 2015 14:11:05 +0300 Subject: [PATCH] Implemented a workaround for certain devices dropping connection after digest authentication challege in connection requests. --- lib/api-functions.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api-functions.coffee b/lib/api-functions.coffee index 5c0fb38..38be33a 100644 --- a/lib/api-functions.coffee +++ b/lib/api-functions.coffee @@ -117,6 +117,9 @@ connectionRequest = (deviceId, callback) -> authString = auth.digest(username, password, uri.path, 'GET', null, authHeader) conReq(connectionRequestUrl, authString, (statusCode, authHeader) -> + if statusCode == 0 + # Workaround for some devices unexpectedly closing the connection + return conReq(connectionRequestUrl, authString, (statusCode) -> callback(statusToError(statusCode))) callback(statusToError(statusCode)) ) else