Giter VIP home page Giter VIP logo

Comments (7)

ra1u avatar ra1u commented on July 17, 2024

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.

ra1u avatar ra1u commented on July 17, 2024

@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.

Peter-717 avatar Peter-717 commented on July 17, 2024

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.

idrats avatar idrats commented on July 17, 2024

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.

ra1u avatar ra1u commented on July 17, 2024

@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.

idrats avatar idrats commented on July 17, 2024

Sorry, I have figured out, that was my mistake

from redis-dart.

ra1u avatar ra1u commented on July 17, 2024

@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)

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.