mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-26 01:48:42 -05:00
Detect closed socket, reconnect, with a bit more grace
This commit is contained in:
parent
31618ce666
commit
4b67df2907
@ -658,20 +658,20 @@ def main(args=args):
|
|||||||
LOG.debug("reset empty line counter")
|
LOG.debug("reset empty line counter")
|
||||||
empty_line_rx = 0
|
empty_line_rx = 0
|
||||||
else:
|
else:
|
||||||
LOG.debug("continue: noise: " + line)
|
LOG.debug("Noise: " + line)
|
||||||
# detect closed socket, getting lots of empty lines
|
# detect closed socket, getting lots of empty lines
|
||||||
if len(line.strip()) == 0:
|
if len(line.strip()) == 0:
|
||||||
LOG.debug("Zero line length received. Consecutive empty line count: " + str(empty_line_rx))
|
LOG.debug("Zero line length received. Consecutive empty line count: " + str(empty_line_rx))
|
||||||
empty_line_rx += 1
|
empty_line_rx += 1
|
||||||
if empty_line_rx >= 30:
|
if empty_line_rx >= 30:
|
||||||
LOG.debug("Excessive empty lines received, socket likely closed. Reconnecting.")
|
LOG.debug("Excessive empty lines received, socket likely CLOSED_WAIT. Reconnecting.")
|
||||||
sock_file.close()
|
sock_file.close()
|
||||||
sock.shutdown(0)
|
sock.shutdown(0)
|
||||||
sock.close()
|
sock.close()
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
setup_connection()
|
setup_connection()
|
||||||
sock.send("user %s pass %s vers https://github.com/craigerl/aprsd 2.00\n" % (user, password))
|
sock.send("user %s pass %s vers https://github.com/craigerl/aprsd 2.00\n" % (user, password))
|
||||||
LOG.debug("reset empty line counter")
|
#LOG.debug("reset empty line counter")
|
||||||
empty_line_rx = 0
|
empty_line_rx = 0
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user