Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eventhub] websocket default timeout fix #24565

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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