From 8d51bc3cfa85a59caa41c7d9b4674bb7fea7fba4 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Sun, 8 Oct 2017 17:53:49 +0200
Subject: [PATCH] [fix] #1141 Immediately close a WS2P connection if it fails

---
 app/modules/ws2p/lib/WS2PClient.ts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/modules/ws2p/lib/WS2PClient.ts b/app/modules/ws2p/lib/WS2PClient.ts
index 00df5c150..a3e599eba 100644
--- a/app/modules/ws2p/lib/WS2PClient.ts
+++ b/app/modules/ws2p/lib/WS2PClient.ts
@@ -36,7 +36,13 @@ export class WS2PClient {
     })
 
     // Connecting
-    await c.connect()
+    try {
+      await c.connect()
+    } catch (e) {
+      // Immediately close the connection
+      c.close()
+      throw e
+    }
     return new WS2PClient(c)
   }
 }
\ No newline at end of file
-- 
GitLab