Skip to content

Commit

Permalink
[eventhub] websocket default timeout fix (Azure#24565)
Browse files Browse the repository at this point in the history
* websocket timeout fix

* timeout interval for both ssl and webscoket
  • Loading branch information
l0lawrence authored and swathipil committed Aug 23, 2022
1 parent 7c4d007 commit 57b529c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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+))?')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
_UNAVAIL,
set_cloexec,
AMQP_PORT,
TIMEOUT_INTERVAL,
WebSocketTransport
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 57b529c

Please sign in to comment.