Merge pull request #424 from oddstr13/broadcast-not-multicast

Remove multicast socket options from autodiscovery
This commit is contained in:
Odd Stråbø 2020-11-15 21:34:51 +01:00 committed by GitHub
commit 4b8f510325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -213,11 +213,7 @@ class ConnectionManager(object):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(1.0) # This controls the socket.timeout exception
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 1)
sock.setsockopt(socket.IPPROTO_IP, socket.SO_REUSEADDR, 1)
LOG.debug("MultiGroup : %s", str(MULTI_GROUP))
LOG.debug("Sending UDP Data: %s", MESSAGE)
@ -232,6 +228,8 @@ class ConnectionManager(object):
return servers
while True:
data = None
addr = None
try:
data, addr = sock.recvfrom(1024) # buffer size
servers.append(json.loads(data))
@ -240,6 +238,9 @@ class ConnectionManager(object):
LOG.info("Found Servers: %s", servers)
return servers
except json.JSONDecodeError:
LOG.warning("Unable to decode %r from %r.", data, addr)
except Exception as e:
LOG.error(traceback.format_exc())
LOG.exception("Error trying to find servers: %s", e)