autobahn-python icon indicating copy to clipboard operation
autobahn-python copied to clipboard

Successful connection doesn't reset the exponential backoff state

Open afk11 opened this issue 1 year ago • 2 comments

When I kill crossbar, I can see python-autobahn doing exponential backoff which is fine, however, if the connection re-establishes, the existing state isn't cleared. So if there is a subsequent disconnect, instead of the retry_delay being 0, it continues to grow the previous retry delay

In these circumstances, small outages cause the retry_delay to accumulate, building up to a 5+ minute wait before it even attempts a connection

I'm looking into how I can reach this from the Component, or if changes need to be made to the library, but I wanted to open this in case anyone has feedback or a workaround

Thanks in advance

afk11 avatar Sep 29 '22 13:09 afk11

It looks like I want to call _Transport.reset() which would reset self.retry_delay = self.initial_retry_delay

https://github.com/crossbario/autobahn-python/blob/master/autobahn/wamp/component.py#L302

afk11 avatar Sep 29 '22 14:09 afk11

I agree that the autobahn infrastructure itself should reset the delay after a successful connect.

One workaround meanwhile could be to set max_retry_delay to something lower than the default (which is 300 seconds).

If you wanted to try to prepare a fix, I believe the right place to call transport.reset() would be somewhere in this "else" clause when the session is set up: https://github.com/crossbario/autobahn-python/blob/master/autobahn/wamp/component.py#L763 (although it's been a while since I've looked at this code).

meejah avatar Sep 29 '22 20:09 meejah