Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-register a WAMP callee after a reconnect using Autobahn Python with Twisted ReconnectingClientFactory?

I have an Autobahn Python client application using Twisted which is connected to a Crossbar.io server. The client application can successfully reconnect after losing network connectivity using the ReconnectingClientFactory. The client registers a callee name when connected so that other applications can call it. This always works on the initial connection.

However, when recovering from a lost connection, the callee name cannot be re-registered because the callee name is still registered from the prior lost connection. This results in the error 'wamp.error.procedure_already_exists'. Because the callee name registration is still associated with the prior lost connection, I am to unregister the old callee name.

The only solution I can see is to generate and register a unique new callee name on each connection to avoid colliding with prior registered callee names.

Is there a better or simpler way to deal with this? It seems that the WAMP protocol would allow unregistering a callee name from another connection using the registration id, but the Autobahn Python client library does not seem to allow this.

like image 248
Harold Short Avatar asked Sep 11 '15 00:09

Harold Short


1 Answers

I was asking the wrong question. The Crossbar.io server should detect when a client is disconnected and automatically unregister callees that belong to that disconnected session (per Tobias Oberstien on Twitter: https://twitter.com/oberstet/status/642241167216746496). This is not the responsibility of the Autobahn clients.

My issue was that my Crossbar.io server was not detecting client disconnects that occur when client network connections were abruptly disconnected, so the cleanup was not occurring.

This behavior is simply due to the configuration of the Crossbar server. I have since followed the "production settings" example documented on the Crossbar site (http://crossbar.io/docs/WebSocket-Options/). I now have the behavior I was looking for, where sessions left over from broken connection are detected and cleaned up automatically.

like image 82
Harold Short Avatar answered Nov 15 '22 18:11

Harold Short