Comments (11)
I'll think about it. Seems like a good idea.
from connectanum-dart.
@jiajun-ifanr could you try this:
connectanum-dart/example/main.dart
Line 22 in c21eb2a
from connectanum-dart.
Hi @konsultaner , I find that after the client is reconnected, it doesn't seem to auto resubscribe to what it has already subscribed to. That's to say, it doesn't listen to data changes again.
@jiajun-ifanr Yes this is totally expected behaviour. This feature is not implemented yet. You may open a new Issue for this feature if you want it. As soon as I get the time, I will implement it. There will be an additional subscribePermanently
as soon as it is implemented. The same issue exists with registrations. They don't stay alive. For now, you may collect your subscriptions and resubscribe them manually in the reconnect event.
from connectanum-dart.
@jiajun-ifanr I'm on it! Havn't had time to work on this yet. I hope you can wait a little longer
from connectanum-dart.
@jiajun-ifanr I'm on it! Havn't had time to work on this yet. I hope you can wait a little longer
No problem! Thank you!
from connectanum-dart.
@konsultaner I tried with the above example, but it seems like it will reconnect only when a session is being initialized. Also when a function is passed to _client.onNextTryToReconnect.listen
, and while it is reconnecting, the function doesn't execute.
I want retries are made when a connection is ongoing and very suddenly the network is disconnected due to some network issues (e.g. connection lost / network change).
Is there any way to detect if the connection is lost and then retry connection?
from connectanum-dart.
What transport do you use? Actually it should also work on connection loss.
connectanum-dart/lib/src/client.dart
Line 88 in a1de7e3
from connectanum-dart.
No, you're right.. it does not push the event...
from connectanum-dart.
I added a quick fix. but I need to write some tests on it... Should work if you use the latest master
from connectanum-dart.
Looks like it works. Thanks again!
from connectanum-dart.
Hi @konsultaner , I find that after the client is reconnected, it doesn't seem to auto resubscribe to what it has already subscribed to. That's to say, it doesn't listen to data changes again.
Please take a glance at the below code as an example. It has a class called Wamp
and it is first instantiated and connected to our server on page load. There's a Subscribe
button and when you click on it, it will subscribe to a topic.
Here's a scenario where the network is suddenly disconnected (for e.g. 40 seconds). Then the network is back online, and the client begins to retry. Once it is successfully reconnected, it is supposed to listen data changes again. But it isn't.
Also when I click the Subscribe
button again, a Bad state: No element
exception is thrown. Any chance to get it worked?
import 'package:flutter/material.dart';
import 'package:connectanum/connectanum.dart';
import 'package:connectanum/json.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
Wamp wamp = new Wamp();
@override
void initState() {
super.initState();
wamp.connect();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Test App'),
),
body: Center(
child: RaisedButton(
onPressed: () {
wamp.subscribe();
},
child: Text('Subscribe'),
)),
);
}
}
class Wamp {
Client client;
Session session;
void connect() async {
String url =
'wss://a4d2d62965ddb57fa4d6.ws.myminapp.com/ws/hydrogen/?x-hydrogen-client-id=a4d2d62965ddb57fa4d6&x-hydrogen-env-id=f1eeb28c9552d4c83df1&authorization=Hydrogen-r1%204prp5lsv9ox8n8r4y6ux6hwuguf9r8fg';
client = Client(
realm: 'com.ifanrcloud',
transport: WebSocketTransport(
url,
new Serializer(),
WebSocketSerialization.SERIALIZATION_JSON,
),
);
try {
session = await client
.connect(
options: ClientConnectOptions(
reconnectCount: 10,
reconnectTime: Duration(
milliseconds: 200,
),
),
)
.first;
client.onNextTryToReconnect.listen((passedOptions) {
print('retrying...');
passedOptions.reconnectTime = Duration(
milliseconds: passedOptions.reconnectTime.inMilliseconds + 500,
);
});
} on Abort catch (abort) {
print(abort.message.message);
}
}
void subscribe() async {
String topic = 'com.ifanrcloud.schema_event.danmu_jiajun.on_create';
var options = new SubscribeOptions();
options.addCustomValue("where", (serializerType) => "{}");
Subscribed subscription = await session.subscribe(topic, options: options);
print('subscribed successfully...');
// listen to data change
// supposed to listen to changes again on reconnection. But it isn't.
subscription.eventStream.listen(
(event) {
print(event.argumentsKeywords.toString());
},
);
}
}
I have tested my JS application counterpart and it works. So it might not be a backend related issue.
Is there a workaround for 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
- Auth failure response doesn't seem right HOT 19
- 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.