Giter VIP home page Giter VIP logo

Comments (19)

malibu1966 avatar malibu1966 commented on August 26, 2024 1

Thanks for the fast response! I am somewhat familiar with streams. I've been doing them in python for some time and I'm trying to make this app all stream based. Admittedly, even after doing a few rxdart tuts and videos I am struggling with them a bit still but I really want to learn.

Assuming the .first was supposed to be there is probably my issue then. Thank you I will focus on your recommendations.

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024 1

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

Hey @malibu1966

The example assumes that you know how Streams in dart work. I should change that example. If you use .first, you will only get the first element and the await succeeds. All following elements will be ignored. You should read the Stream-Section of the Dart docs.

You could use either a for loop or the listen() method to read the stream and all errors coming from that stream.

You could also check the libraries test cases to see how it works.

Sorry for the trouble 🙈

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

@malibu1966 here is a good example from the test

client
.connect()
.listen((_) {}, onError: ((abort) => abortCompleter.complete(abort)));

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

please close if you find this issue is solved for you!

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

I did this already but I'm still getting the errors?

            Completer abortCompleter = Completer<Abort>();
            var subscription = client!
                .connect(
                    options: ClientConnectOptions(
                     reconnectCount: 0, // Default is 3
                     reconnectTime: const Duration(
                         milliseconds: 200) // default is null, so immediately
                     // you may add ping pong options here as well
                ))
                .listen((data) {session = data;}, onError: ((abort) => abortCompleter.complete(abort)));
            Abort abort = await abortCompleter.future;
            print("ABORT RECEIVED");

It never gets to the print statement. I tried it with different reconnectCount values and with .listen( (_) {}, onError: as it is in the test as well. If I take out the options and just use .connect() I still get that null error.

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

do you have your project on github? I would check it out and give it a try. I know that the guys from crossbar are actually using this lib for an internal project. they also contributed. It should work. maybe the ticket authenticator has a problem. have you tried wamp-cra?

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

did you set a reconnectTime ?

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

Yes the reconnectTime is set to 200 ms as per the demo.

I will set up a static CRA and try it. Perhaps I will try the crossbar forum and see if anyone can assist there.

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

I will digg into it.

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

@KSDaemon have you experienced similar issues with your implementation?

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

I'm not absolutely sure what you mean by that. I used MDWamp for my native iOS app and it seems to work fine in this circumstance; it calls onDisconnect and I report the error.

In python I have a problem where it won't stop reconnecting but apparently that is for a different reason, I have to stop the app component rather than stopping the session. Also that is different in that it doesn't go into an internal loop. It does the reconnect cycle until the correct ID and password are entered. Also, neither ios or python versions are stream based. Did that answer your question?

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

I tried a basic static ticket auth and it does the same thing.
I tried CraAuthentication and the server gives "WAMP-CRA client signature is invalid (expected X but got Y)" even for correct credentials.

I'm using crossbar server 22.6.1, I think tomorrow I will try upgrading to 22.7.1

from connectanum-dart.

KSDaemon avatar KSDaemon commented on August 26, 2024

Hm... Really strange. We do not have such problems. We are doing all types of auth without problems.

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

What version of crossbar are you using? I can't upgrade to 22.7.1 because it's not in Pypi.

Can you provide me with an example of code that handles errors?
Is it possible something has changed in the dependencies?

Here is my entire client class. I know it's not complete, but do you see a reason why it wouldn't connect with a static CRA method if the credentials are correct? I do get to the ABORT RECEIVED but then after that I get the looping exceptions again.

I really appreciate the help on this.

import 'package:connectanum/connectanum.dart';
import 'package:connectanum/authentication.dart';
import 'package:connectanum/json.dart';
import 'dart:async';
import 'package:tactical_flutter/data/abstract_wamp_client.dart';
class ParamException implements Exception {
    String errMsg() => 'BasicWampClient should have username and password';
}
class ConnectionException implements Exception {
    String errMsg() => 'Not able to connect';
}

class BasicWampClient extends AbstractWampClient {
    StreamSubscription<Session>? client_subscription;
    BasicWampClient();

    @override
    void connect({String? username,String? uid, String? password}) async {
        if (username != null && password != null && uid == null) {
            var transport = WebSocketTransport(
                "ws://6.6.6.2:9000/test",
                Serializer(),
                WebSocketSerialization.serializationJson
            );
            client = Client(
                authId: username,
                authenticationMethods: [CraAuthentication(password)],
                realm: "myrealm",
                transport: transport
            );
            Completer abortCompleter = Completer<Abort>();
            client_subscription = client!
                .connect(options: ClientConnectOptions(
                reconnectCount: 1, // Default is 3
                reconnectTime: const Duration(
                    milliseconds: 200)))
                .listen((data){
                    session = data;
                    }, onError: ((abort) => abortCompleter.complete(abort)));
            Abort abort = await abortCompleter.future;
            print("ABORT RECEIVED");
        }
        else {
            throw ParamException();
        }

    }
}

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

So, I found this comment in websocket_transport_io.dart:

/// This transport type is used to connect via web sockets
/// in a dart vm environment. A known issue is that this
/// transport does not support auto reconnnect in the dart vm
/// use [SocketTransport] instead! This may not work if your
/// router does not raw socket transport.

I could have sworn that I had tried disabling reconnectCount before, but either I did not do it right or because I hadn't completed onReady/onDisconnect/onConnectionLost I wasn't interpeting results correctly.

Anyway, I guess if you need to use WebSocketTransport you can't have autoconnecting and the reconnectCount value must be 0?

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

@malibu1966 thats embarrassing 😖 I totally forgot about it. There has been an issue with the default libs from dart not supporting all states necessary to handle reconnection. This has been an issue right from the beginning. Can you use RawSockets?

from connectanum-dart.

malibu1966 avatar malibu1966 commented on August 26, 2024

I don't know, I have never tried rawsockets. I have around four different directories and three different auth methods. Can I do that with rawsockets? I also have a Swift iOS app and a python application and a bunch of python microservices that are already working with this server. It may just be easier for me to trigger on an onConnectionLost and handle reconnects manually.

from connectanum-dart.

konsultaner avatar konsultaner commented on August 26, 2024

@malibu1966 there is a new version that has a fully rewritten code for reconnect. can you try this?

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.