Hello, I am developing a simple WAMP application in Python using Autobahn which involves devices connecting to and communicating through a remote Crossbar router.
For the most part all of the basic features are working very well (connecting, PubSub, RPC, requesting info from the router), however, the application does not react in any way to losing the connection to the router. onLeave and onDisconnect are not called, and there isn’t a single debug message printed to the console indicating a connection failure. The Crossbar router sees that the device has disconnected and notifies other devices subscribed to ‘wamp.session.on_leave’, however the application just hangs until I close it (Ctrl+c), at which point onLeave and onDisconnect are called and I see the debug messages in the console that I expected to see at the time of the actual connection loss. I am testing this with the most basic sample code I could find in the Autobahn Python documentation, and pulling out the network cable from the device to cause the disconnection.
from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner
def init(self, config = None):
def onChallenge(self, challenge):
print(“authentication challenge received”)
def onJoin(self, details):
def onLeave(self, details):
if name == ‘main’:
runner = ApplicationRunner(url = u"ws://address_of_wamp_router", realm = u"realm1")
I did some searching and found a couple examples of setting up ReconnectingClientFactory to automatically reattempt the connection, but this unfortunately didn’t work for my use case either. The best I was able to get was the application would automatically reattempt to connect when the initial connection failed, but not when an established connection had been lost.
I found this topic this topic from a few months ago from someone with this exact same problem, but unfortunately there are no replies. I have tried the code in this link, along with many modifications, but I have not been able to make it work.
If anyone could help me figure out where I am going wrong or point me to a Python WAMP code example that demonstrates either connection failure handling or automatic reconnection I would be very appreciative.