From f1a54bd7d0e7fcd8b8add577d26ed5ef417b5399 Mon Sep 17 00:00:00 2001
From: shortcutme <tamas@zeronet.io>
Date: Sun, 20 Jan 2019 16:15:32 +0100
Subject: [PATCH] Set strict timeout for connection handshake

---
 src/Connection/Connection.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py
index 35703b41..ed1bb703 100644
--- a/src/Connection/Connection.py
+++ b/src/Connection/Connection.py
@@ -164,13 +164,14 @@ class Connection(object):
                 self.sock.settimeout(30)
                 self.sock.connect(sock_address)
 
-        self.sock.settimeout(timeout_before)
 
         # Detect protocol
         self.send({"cmd": "handshake", "req_id": 0, "params": self.getHandshakeInfo()})
         event_connected = self.event_connected
         gevent.spawn(self.messageLoop)
-        return event_connected.get()  # Wait for handshake
+        connect_res = event_connected.get()  # Wait for handshake
+        self.sock.settimeout(timeout_before)
+        return connect_res
 
     # Handle incoming connection
     def handleIncomingConnection(self, sock):