Expose auto-reconnect knobs
See original GitHub issueWe still have the “new API” issue open, where a whole new, “better” API was discussed - we no final conclusion yet. But we need auto-reconnect now. So here is a pragmatic approach with only slight API changes, which would allow to handle reconnects, as well as more flexibility.
- Rename
autobahn.twisted.wamp.ApplicationSession
toautobahn.twisted.wamp.Component
- Rename
autobahn.twisted.wamp.ApplicationRunner
toautobahn.twisted.wamp.Client
- A
Client
can have instances ofComponents
be added, and then theClient
can be started:
component = Component(extra={u'foo': u'bar'})
client = Client(url=u'ws://localhost:8080/ws')
client.connect(realm=u'realm1', autoreconnect=True)
react(client.start)
The Client.start()
method returns a Deferred
that fires when the Component.onDisconnect()
callback ends and does not recall into Component.connect()
.
The Component.onDisconnect()
callback can call Component.connect()
to reconnect, or can return a plain or deferred value or exception.
When Component.onDisconnect()
ends, the Client.start()
method will end.
The autoreconnect
option on the Client.connect()
method activates a default implementation of Component.onDisconnect()
which does not end, but reconnects the component.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
… But we need auto-reconnect now …
For sure … I really think there are a lot of autobahn-python new users, which could be completely disappointed about this auto-reconnect missing feature. Nowadays, in the connected area, with smartphones which loose frequently the connection … an autobahn component is useless.
I really think it’s really most important than a new api
this has been fixed, pls see https://github.com/crossbario/autobahn-python/blob/299a6560cc8bd8e3ad7c02acf6cf15cf15cee87b/autobahn/twisted/wamp.py#L118