Skip to content

Commit

Permalink
Merge pull request #17 from signalfx/SWAT-4643
Browse files Browse the repository at this point in the history
prevent "Connection reset by peer" error on the server side
  • Loading branch information
dloucasfx authored Jun 23, 2022
2 parents 8c4ec9e + e3021c6 commit 58f1ade
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions zk-collectd.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ def _send_cmd(self, cmd):
s.settimeout(self._timeout)

s.connect(self._address)
s.send(cmd.encode("utf-8"))

response = s.recv(2048)
s.sendall(cmd.encode("utf-8"))
s.shutdown(socket.SHUT_WR)

while 1:
data = s.recv(2048)
if len(data) == 0:
break
response += data
s.close()
except socket.timeout:
log('Service not healthy: timed out calling "%s"' % cmd)
Expand Down

0 comments on commit 58f1ade

Please sign in to comment.