Giter VIP home page Giter VIP logo

Comments (1)

konsultaner avatar konsultaner commented on July 23, 2024

@KSDaemon I tried to fix this issue, but then I realized some things.

A transport may have issues before and after the session creation. For example when a cluster is rolled out and the router is avalable after the client. The client would have to try to reconnect until the router is available. Also if the router for some reason crashes after the session creation and the client then reconnects after the router has been restarted.

Connectanum-dart only reconnects if transport layer issues appears. If the router kills the connection with an Abort, the client will not try to restart. This is done by having two Completer the onConnectionLost and onDisconnect. Only onConnectionLost will make the client try to reconnect. The Session and the Client object will only call the onDisconnect or transport.close() if something on the wamp-layer happens.

I had to fix one issue. When adding the wamp.error.no_such_role, wamp.error.no_such_topic and the wamp.error.no_such_session authentication error, one must have missed to add it to the authentication failures in the client.dart. I will add this and push it later.

So I think:

Transport failures before session is established

Transport failures during session. Definitely the most important point to proceed with reconnection (if it is configured)

Should lead to a reconnect, if configured

Wamp abort (due to auth or other reasons) before session is established. Wamp error means that server processed client messages and get to some point that resolves in abort. Does auto reconnection fix this? Seems that not.

Wamp failures during session. Seems that this situations should not lead to reconnection. As they happens when something is broken on business logic side (like using feature that is not announced, using serializer that is not supported etc), so autoreconnection won't automatically fix them.

This should be configurable. The client currently has an Error map that will decide if the client will try to reconnect on auth problems. This will only happen once. There is no second retry. Imagine a situation where a client tries to authenticate, but the database is not up or down at the moment. The router must fail the authentication and it might do so with a lie to hide the original reason. If the client tries to reconnect and the database is available again, the authentication would succeed the second time. So I guess even this scenario should be configurable.

if (![
Error.notAuthorized,
Error.noPrincipal,
Error.authorizationFailed,
Error.noSuchRealm,
Error.protocolViolation
].contains(abort.reason) &&
options.reconnectTime != null) {
// if the router restarts we should wait until it has been initialized
await Future.delayed(Duration(seconds: 2));
options.reconnectCount = 0;
_connect(options);
} else {

If a session has been esteblished an Abort will lead into a transport.close() and thus into a onDisconnect which will not start a reconnect. Due to the WAMP protocol definition a protocol violation will send an Abort. An Error should not be a reason for a connection loss.

} else if (message is Abort) {
try {
transport.close();
} catch (ignore) {/* my be already closed */}
welcomeCompleter.completeError(message);
} else if (message is Goodbye) {

So what do you think?

I think I should make it more configurable. Add a reconnectOnAuthError:bool and a authErrorForReconnectList:array or something like this. And maybe have a special handler that will be notifyed on Abort. The individual client may decide wether to reconnect or not?

from connectanum-dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.