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

Leaving a Component-attached session or stopping a Component causes infinite connection loop

Open JustinTArthur opened this issue 6 years ago • 4 comments

If a router replies to Autobahn's goodbye with a standards-compliant response like wamp.close.goodbye_and_out, the Component establishes a new connection. This will continue in an infinite loop.

The router's goodbye reply results in the protocol's success callback firing a new "leave" event. This triggers the Component's leave handler, which considers any leaving reason beyond wamp.close.normal to be an error, triggering a new connection somewhere downstream in the Component behaviors.

JustinTArthur avatar May 03 '19 07:05 JustinTArthur

It seems like adding wamp.close.goodbye_and_out to the list of "close messages that are considered normal and final" is a good idea.

What about wamp.close.system_shutdown, wamp.close.close_realm and wamp.close.system_shutdown? Conversely, maybe any wamp.close.* should be considered fine and normal and only wamp.close.protocol_violation should be considered an error?

meejah avatar May 03 '19 17:05 meejah

Error or not, we may still want to stop reconnection behavior after we've sent our own goodbye.

JustinTArthur avatar May 04 '19 01:05 JustinTArthur

A work-around for now is to pass an is_fatal predicate function that returns True for any of the ApplicationError strings you want (beyond wamp.close.normal which will already end the re-connections).

meejah avatar May 04 '19 19:05 meejah

Oh, and there's also Component.stop which should call .leave() on a session (if there is one) and then stop the component re-connecting etc (and once all the Components given to run are stopped, the process should exit).

meejah avatar May 04 '19 19:05 meejah