Comments (7)
Thank You for your input.
Seems to be connected with #15 and I have to admit that I was not able to make much of an progress since. I will try to take another look and I hope to move this issue forward.
from redis-dart.
@Peter-717 are you able to write code in way to be included in test and to reproduce bug. You can publish code here in this thread or other way you find appropriate. That would be valuable in better understanding of Your particular issue and might additionally benefit other users.
Kind regards, Luka
from redis-dart.
Hi Luka,
Here is the code. This is basically the Flutter starter app. The Floating button calls the .close() that generates the issue.
I am using a local Redis Server. And I am subscribing to the 'test' channel. When I publish any message on that channel, it will be displayed in the app.
Let me know if I can be of any further assistance. Thanks!
Note: One more thing, how can test that the connection is still alive with the server, as in PubSub mode, we can no longer send a PING command. Thanks
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:redis/redis.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Pub Sub Redis'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@OverRide
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State{
String messageRedis;
String now;
Command _command;
Stream stream;
StreamSubscription subscription;
RedisConnection _redisConnection = new RedisConnection();
PubSub pubSub;
Future finish() async {
pubSub.unsubscribe(['']);
await subscription.cancel();
try {
await _redisConnection.close();
} on HandleUncaughtErrorHandler catch(e) {
print('HandleUncaught: $e');
}
}
Future generateConnect() async {
print('In generate connect');
try {
_command = await _redisConnection.connect('127.0.0.1', 6379);
} on HandleUncaughtErrorHandler catch(e) {
print('Generate Connect ERROR: $e');
if (e.toString().contains('SocketException')){
print('Caught the socket Exception');
}
}
return _command;
}
Future startRedis() async {
try {
Command command = await generateConnect();
pubSub = PubSub(command);
pubSub.subscribe(['test']);
stream = pubSub.getStream();
onData(dynamic value){
setState(() {
messageRedis = value.toString();
now = DateTime.now().toString();
});
}
subscription = stream.listen(onData);
} on Exception catch (e) {
print('Start Redis: $e');
}
}
@OverRide
void initState() {
super.initState();
startRedis();
}
@OverRide
void dispose() {
subscription.cancel();
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
now ?? 'Nothing yet',),
Text(messageRedis ?? 'No message yet',
style: Theme.of(context).textTheme.display1),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {await finish();},
tooltip: 'Increment',
child: Icon(Icons.stop),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
from redis-dart.
I faced with practically the same error. In my case it was Bad state: StreamSink is closed
You can reproduce it simply making 2 calls of redis with the same key immediately
from redis-dart.
@idrats Thak you for report.
Can you please post short and working example of code, so that we are able to reproduce this?
from redis-dart.
Sorry, I have figured out, that was my mistake
from redis-dart.
@idrats that is great :)
I am now closing this, since we did made some progress in recent release, for this thing.
If someone finds an issue, please do open new issue and if possible post code to reproduce this.
from redis-dart.
Related Issues (20)
- FormatException with Byte data on topic HOT 8
- How to authenticate in the connection? HOT 1
- JSON updates with $ - Expected an identifier by Dart HOT 1
- Redis doesn't work on flutter web HOT 1
- implement a way to automatically reconnect and resubscribe if the Redis server is restarted
- SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 56388 HOT 1
- How to check redis connect or not? is there any command to check ?
- While connecting to redis getting SocketException: Connection refused , address = localhost, port = 45042
- connect with authentication HOT 2
- refactor: Upgrade api to match latest dart conventions HOT 10
- JSON.GET <key> <JSON Path> not working HOT 2
- Redis dart licence change - Need your Feedback! HOT 7
- Connection cannot be closed HOT 2
- it's support redis cluster? HOT 1
- Example code
- Whether to support ssl connection HOT 1
- Does this plug-in support ssl? HOT 5
- how to cosume Redis Streams / Lists HOT 1
- RedisRuntimeError(got element that cant not be parsed) HOT 1
- Slow performance when reading from pub sub and adding to Redis Streams HOT 5
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 redis-dart.