diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_transport.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_transport.py index c89beb8286de..b98411c12e1c 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_transport.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/_transport.py @@ -87,6 +87,7 @@ def set_cloexec(fd, cloexec): # noqa AMQP_FRAME = memoryview(b'AMQP') EMPTY_BUFFER = bytes() SIGNED_INT_MAX = 0x7FFFFFFF +TIMEOUT_INTERVAL = 1 # Match things like: [fe80::1]:5432, from RFC 2732 IPV6_LITERAL = re.compile(r'\[([\.0-9a-f:]+)\](?::(\d+))?') @@ -148,7 +149,7 @@ def __init__(self, host, port=AMQP_PORT, connect_timeout=None, self.raise_on_initial_eintr = raise_on_initial_eintr self._read_buffer = BytesIO() self.host, self.port = to_host_port(host, port) - self.connect_timeout = connect_timeout + self.connect_timeout = connect_timeout or TIMEOUT_INTERVAL self.read_timeout = read_timeout self.write_timeout = write_timeout self.socket_settings = socket_settings @@ -658,9 +659,9 @@ def Transport(host, transport_type, connect_timeout=None, ssl=False, **kwargs): return transport(host, connect_timeout=connect_timeout, ssl=ssl, **kwargs) class WebSocketTransport(_AbstractTransport): - def __init__(self, host, port=WEBSOCKET_PORT, connect_timeout=1, ssl=None, **kwargs): + def __init__(self, host, port=WEBSOCKET_PORT, connect_timeout=None, ssl=None, **kwargs): self.sslopts = ssl if isinstance(ssl, dict) else {} - self._connect_timeout = connect_timeout + self._connect_timeout = connect_timeout or TIMEOUT_INTERVAL self._host = host super().__init__( host, port, connect_timeout, **kwargs diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py index ea679ebd392c..66f3187ab7d7 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_pyamqp/aio/_transport_async.py @@ -60,6 +60,7 @@ _UNAVAIL, set_cloexec, AMQP_PORT, + TIMEOUT_INTERVAL, WebSocketTransport ) @@ -418,13 +419,13 @@ async def negotiate(self): class WebSocketTransportAsync(AsyncTransportMixin): - def __init__(self, host, port=WEBSOCKET_PORT, connect_timeout=1, ssl=None, **kwargs + def __init__(self, host, port=WEBSOCKET_PORT, connect_timeout=None, ssl=None, **kwargs ): self._read_buffer = BytesIO() self.loop = get_running_loop() self.socket_lock = asyncio.Lock() self.sslopts = ssl if isinstance(ssl, dict) else {} - self._connect_timeout = connect_timeout + self._connect_timeout = connect_timeout or TIMEOUT_INTERVAL self.host = host self.ws = None self._http_proxy = kwargs.get('http_proxy', None)