handle join_group errors

This commit is contained in:
Jack Robison 2018-10-10 14:15:24 -04:00
parent 040faedbf9
commit 28c01b5b31
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 8 additions and 4 deletions

View file

@ -37,7 +37,6 @@ class MulticastProtocol(DatagramProtocol):
def connection_made(self, transport) -> None: def connection_made(self, transport) -> None:
self.transport = transport self.transport = transport
self.join_group(self.multicast_address, self.bind_address)
@classmethod @classmethod
def create_multicast_socket(cls, bind_address: str): def create_multicast_socket(cls, bind_address: str):

View file

@ -112,10 +112,15 @@ async def listen_ssdp(lan_address: str, gateway_address: str,
) )
transport: DatagramTransport = listen_result[0] transport: DatagramTransport = listen_result[0]
protocol: SSDPProtocol = listen_result[1] protocol: SSDPProtocol = listen_result[1]
except Exception as err:
raise UPnPError(err)
try:
protocol.join_group(protocol.multicast_address, protocol.bind_address)
protocol.set_ttl(1) protocol.set_ttl(1)
except Exception: except Exception as err:
log.exception("failed to create multicast socket %s:%i", lan_address, SSDP_PORT) transport.close()
raise raise UPnPError(err)
return transport, protocol, gateway_address, lan_address return transport, protocol, gateway_address, lan_address