Comments (19)
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.
from connectanum-dart.
Hey @malibu1966
The example assumes that you know how Stream
s 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.
@malibu1966 here is a good example from the test
connectanum-dart/test/client_test.dart
Lines 98 to 100 in a9ecb58
from connectanum-dart.
please close if you find this issue is solved for you!
from connectanum-dart.
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.
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.
did you set a reconnectTime
?
from connectanum-dart.
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.
I will digg into it.
from connectanum-dart.
@KSDaemon have you experienced similar issues with your implementation?
from connectanum-dart.
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.
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.
Hm... Really strange. We do not have such problems. We are doing all types of auth without problems.
from connectanum-dart.
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.
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.
@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.
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.
@malibu1966 there is a new version that has a fully rewritten code for reconnect. can you try this?
from connectanum-dart.
Related Issues (20)
- Add way more logging!
- Resubscribe to Topics on Reconnection HOT 2
- Was there dublicate sessions fix from version 1.0.6 to 1.1.6 HOT 1
- WAMPCRA: Only derive key when `salt` present in Challenge HOT 11
- Session call arguments type HOT 2
- session.publish seem to stuck HOT 4
- Session.publish with PublishOptions(acknowledge: false) waits for `PUBLISHED`
- Strange behaviour of Session.publish and/or Session.subscribe HOT 2
- Session.call seem to block HOT 3
- Cache stored key for scram authentication
- Support multiple serializers HOT 18
- Implement CBOR serializer HOT 15
- Better reconnection handling HOT 1
- Implement Payload PassThru Mode HOT 4
- Flaute WebApp Chrome Webhost is not supporting dart.html HOT 9
- not connect websocket HOT 2
- Currently the connection doesn't support authextra HOT 2
- Unable to catch error HOT 7
- Support dart2wasm compilation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connectanum-dart.