Commit b9f8d553 authored by Luke Macken's avatar Luke Macken

Merge pull request #20 from ryazwinski/develop

handle failed reverse connections gracefully
parents c6a3ac53 4b5e9293
...@@ -70,13 +70,18 @@ class ReverseConnection(threading.Thread, PyrasiteIPC): ...@@ -70,13 +70,18 @@ class ReverseConnection(threading.Thread, PyrasiteIPC):
continue continue
break break
if not self.sock:
raise Exception('pyrasite cannot establish reverse connection to %s:%d' % (self.host, self.port))
self.on_connect() self.on_connect()
while running: while running:
cmd = self.recv() cmd = self.recv()
if cmd is None or cmd == "quit\n" or len(cmd) == 0: if cmd is None or cmd == "quit\n" or len(cmd) == 0:
running = False running = False
else: else:
running = self.on_command(cmd) running = self.on_command(cmd)
except Exception as e: except Exception as e:
print(str(e)) print(str(e))
running = False running = False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment