AutobahnPython managing lost connections

#1

Hi,

I’m currently writing a WAMP application with an AutobahnJS webpage an and an AutobahnPython application connecting to a Crossbar router on a VPS.

The AutobahnPython app will be used through a business WiFi connection which suffers from disconnects.

transport_factory is a class inheriting from WampWebSocketClientFactory and ReconnectingClientFactory.

I set the following options before connecting to attempt to detect connection issues. However, even with debug_wamp on, I see no pings at all.

transport_factory.setProtocolOptions(autoPingInterval=10.0, autoPingTimeout=3.0)

``

So far, with the ReconnectingClientFactory, I can get my application to wait and retry if the server dies.

However, in my tests at home, if I cut the Wifi connection or am still connected to my router and intentionally cut the Internet,

the ApplicationSession will just hang infinitely.

The problem with this is that I have another LoopingCall running on the reactor that needs to monitor hardware whatever the connection is. This LoopingCall works as intended, but I would need it to be notified when there is no connection in this case.

0 Likes

#2

So I made a custom protocol class inheriting from WampWebSocketClientProtocol where I did an override to the onConnect method:

def onConnect(self, response):
returnVal = super(Protocol, self).onConnect(response)

if self.autoPingInterval:
    self.autoPingPendingCall = self.factory._callLater(self.autoPingInterval, self._sendAutoPing)

return returnVal

``

I looked at the source code of the protocol classes and autoping is generated only in the server protocol in succeedHandshake. In the Client class, there is nothing ever creating the call.

However, I now have autopings both from crossbar and from the client. Maybe I should update a time variable when onPing is called on the client and see if it hasn’t been updated for a while in my other LoopingCall.

···

Le samedi 4 avril 2015 12:25:55 UTC-4, Antoine Deschênes a écrit :

Hi,

I’m currently writing a WAMP application with an AutobahnJS webpage an and an AutobahnPython application connecting to a Crossbar router on a VPS.

The AutobahnPython app will be used through a business WiFi connection which suffers from disconnects.

transport_factory is a class inheriting from WampWebSocketClientFactory and ReconnectingClientFactory.

I set the following options before connecting to attempt to detect connection issues. However, even with debug_wamp on, I see no pings at all.

transport_factory.setProtocolOptions(autoPingInterval=10.0, autoPingTimeout=3.0)

``

So far, with the ReconnectingClientFactory, I can get my application to wait and retry if the server dies.

However, in my tests at home, if I cut the Wifi connection or am still connected to my router and intentionally cut the Internet,

the ApplicationSession will just hang infinitely.

The problem with this is that I have another LoopingCall running on the reactor that needs to monitor hardware whatever the connection is. This LoopingCall works as intended, but I would need it to be notified when there is no connection in this case.

0 Likes