Automatic reconnection
ecorm opened this issue · 3 comments
Provide automatic reconnection facilities. If a connection is dropped unexpectedly, CppWAMP would re-establish the session using the list of connector objects. It should also re-register RPCs and re-subscribe to events.
Any updates on this? Any pointers to where to implement the fix?
Like I said for your other comment: Sorry, I haven't yet put any thought in how I'd implement this. It's not an urgent feature for my project because Crossbar is hosted on the same device as my C++ program.
Session state change callbacks (#78) are now implemented in 637589d. This should allow the user to implement their own reconnection logic.
I'm not sure yet what would be a sensible policy for an automatic reconnection feature provided by CppWAMP. Things to consider:
- Lengthening the intervals between reconnection attempts when the first attempt fails
- Number of retries before giving up
Another thing to consider is that Registration
and Subscription
objects become invalidated when a new session is established.
The current design with internal::Client
objects being created for every Session
connection operation admittedly makes things complicated. The rationale was to avoid virtual function calls when using the TCodec
bound to the Client
instance. In hindsight, the resulting complexity is not worth the potential performance gains, which I never even measured.
I'm therefore placing this feature on the back burner considering that the user now has a means to react to session disconnection/failure events. I'll take a look at it again if I get the chance to refactor the current design to favor runtime polymorphism over compile-time (i.e. template) polymorphism.
I'll take this opportunity to make a note to myself to keep an eye on the proposed Session Resumption WAMP protocol feature.