diff --git a/aioupnp/protocols/multicast.py b/aioupnp/protocols/multicast.py index ab5ce78..2068dc6 100644 --- a/aioupnp/protocols/multicast.py +++ b/aioupnp/protocols/multicast.py @@ -37,7 +37,6 @@ class MulticastProtocol(DatagramProtocol): def connection_made(self, transport) -> None: self.transport = transport - self.join_group(self.multicast_address, self.bind_address) @classmethod def create_multicast_socket(cls, bind_address: str): diff --git a/aioupnp/protocols/ssdp.py b/aioupnp/protocols/ssdp.py index 4b523c0..b859e74 100644 --- a/aioupnp/protocols/ssdp.py +++ b/aioupnp/protocols/ssdp.py @@ -112,10 +112,15 @@ async def listen_ssdp(lan_address: str, gateway_address: str, ) transport: DatagramTransport = listen_result[0] 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) - except Exception: - log.exception("failed to create multicast socket %s:%i", lan_address, SSDP_PORT) - raise + except Exception as err: + transport.close() + raise UPnPError(err) + return transport, protocol, gateway_address, lan_address