From 5887f902027b25f53876d7864af7d1798a992c3e Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sun, 26 Aug 2018 22:54:45 +0200 Subject: [PATCH] Wait handshake done before sending other request to connections --- src/Connection/Connection.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index 5a051a54..5305b130 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -475,6 +475,10 @@ class Connection(object): self.log("Send error: missing socket") return False + if not self.connected and message.get("cmd") != "handshake": + self.log("Wait for handshake before send request") + self.event_connected.get() + try: stat_key = message.get("cmd", "unknown") if stat_key == "response": @@ -499,7 +503,7 @@ class Connection(object): with self.send_lock: self.sock.sendall(data) except Exception, err: - self.close("Send error: %s" % err) + self.close("Send error: %s (cmd: %s)" % (err, stat_key)) return False self.last_sent_time = time.time() return True