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

Bad error handling in the autobahn_autoreconnect file #1618

Open
richardmu92129 opened this issue Apr 17, 2023 · 0 comments
Open

Bad error handling in the autobahn_autoreconnect file #1618

richardmu92129 opened this issue Apr 17, 2023 · 0 comments

Comments

@richardmu92129
Copy link

My team and I noticed the following alarming behavior of autobahn’s retry policy when an invalid/bogus URL is given for the _connect function in the init.py file:

• Instead of implementing the default retry policy of trying to reconnect in 1, 2, 4, 8, 16, etc seconds, the _connect function is instead spamming the server with retry requests multiple times per second!
• This is due to the fact that the _reconnect function does not have a delay or retry policy
o If the retry fails, _reconnect calls the _connect function immediately, which then calls _reconnect right away when that fails, and so on.
• This leads to a system spamming our corporate network with a flood of connection requests, which causes the network to prevent any other systems from connecting. This is very troublesome as it practically prevents any of our systems from connecting to the network!
• The python version we are using is 3.6.2

We are trying to understand why the invalid URL case does not get handled as a retry (except OSError) but rather that the reconnect happens instantaneously. The affected source code is shown below

@asyncio.coroutine
def _connect(self):
self._active_protocol = None
self._retry_strategy.reset_retry_interval()
while True:
try:
_, protocol = yield from self._loop.create_connection(self._transport_factory, self._host, self._port, ssl=self._ssl)
protocol.is_closed.add_done_callback(self._reconnect)
self._active_protocol = protocol
return
except OSError:
print('Connection failed')
if self._retry_strategy.retry():
retry_interval = self._retry_strategy.get_retry_interval()
print('Retry in {} seconds'.format(retry_interval))
yield from asyncio.sleep(retry_interval)
else:
print('Exceeded retry count')
self._loop.stop()
raise ExceededRetryCount()

            self._retry_strategy.increase_retry_interval()

def _reconnect(self, f):
    # Reconnect
    print('Connection lost')
    if not self._closing:
        print('Reconnecting')
        asyncio.async(self._connect(), loop=self._loop)
@richardmu92129 richardmu92129 changed the title Error handling in the autobahn_autoreconnect file Bad error handling in the autobahn_autoreconnect file Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant