Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exited(255) Unhandled exception: SocketException: Write failed (OS Error: Broken pipe, errno = 32), address = 127.0.0.1, port = 63467 #49

Closed
Caesar0 opened this issue Oct 20, 2021 · 10 comments
Labels

Comments

@Caesar0
Copy link

Caesar0 commented Oct 20, 2021

Occurs when the redis service shuts down unexpectedly!

=====================================================================================

Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), address = 127.0.0.1, port = 63467
#0      _NativeSocket.write (dart:io-patch/socket_patch.dart:1119:34)
#1      _RawSocket.write (dart:io-patch/socket_patch.dart:1765:15)
#2      _Socket._write (dart:io-patch/socket_patch.dart:2198:18)
#3      _SocketStreamConsumer.write (dart:io-patch/socket_patch.dart:1946:26)
#4      _SocketStreamConsumer.addStream.<anonymous closure> (dart:io-patch/socket_patch.dart:1920:11)
#5      _rootRunUnary (dart:async/zone.dart:1444:13)
#6      _RootZone.runUnaryGuarded (dart:async/zone.dart:1623:7)
#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#8      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#9      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#10     _StreamController._add (dart:async/stream_controller.dart:607:7)
#11     _StreamController.add (dart:async/stream_controller.dart:554:5)
#12     _StreamSinkImpl.add (dart:io/io_sink.dart:136:17)
#13     _Socket.add (dart:io-patch/socket_patch.dart:2045:38)
#14     RedisConnection._sendraw
package:redis/connection.dart:75
#15     Command.send_object
package:redis/command.dart:27
#16     Cas.watch.<anonymous closure>
package:redis/cas.dart:31
#17     Future.doWhile.<anonymous closure> (dart:async/future.dart:535:26)
#18     _rootRunUnary (dart:async/zone.dart:1436:47)
#19     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#21     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1281:26)
#22     Future.doWhile (dart:async/future.dart:551:18)
#23     Cas.watch
package:redis/cas.dart:29

@ra1u ra1u added bug and removed bug labels Oct 20, 2021
@ra1u
Copy link
Owner

ra1u commented Oct 20, 2021

I think that you need are missing appropriate error catching.

What you receive is exception of type SocketException that is result of disconnect.

What do you to expect from this redis-dart library when redis service shuts down unexpectedly and socket is shut down?

@Caesar0
Copy link
Author

Caesar0 commented Oct 22, 2021

import 'dart:async';

import 'package:redis/redis.dart';

Future main(List<String> args) async {
  try {
    RedisConnection connection = RedisConnection();
    var cmd = await connection.connect('127.0.0.1', 6379);
    Timer.periodic(Duration(milliseconds: 1000), (p0) async {
      try {
        var ret = await cmd.send_object(['get', 'test']);
        print(ret);
      } catch (e) {
        print('tiemr:${e.toString()}');
      }
    });
  } catch (e) {
    print(e.toString());
  }
  await Future.delayed(Duration(milliseconds: 10000));
}

When redis server closed, my application crashed.
QQ20211022-185115@2x

I expect don't crash when redis service shuts down unexpectedly and socket is shut down.

@ra1u
Copy link
Owner

ra1u commented Oct 22, 2021

That is interesting.
It is not yet clear where this error comes from. Is that 3rd invocation of cmd.send_object() and why that could be?

I will try to take deeper look later when I will have more time.

Thank You for your report.

@ra1u
Copy link
Owner

ra1u commented Oct 23, 2021

I have now repeated similar issue on with similar approach using StreamQueue<T> as I wanted to replace StreamNext hoping for better results.

To test this, you need tcp echo server (not included here) and and than kill server after running this dart script
https://gist.github.com/ra1u/06c87ad5b04e0510d9b3b2820e215746

Here is ouput error
https://gist.github.com/ra1u/1fd2c4b52af68f241b212deb6de2b508

Has anyone have idea what is going on. Otherwise I will try to find support with dart support.

@ra1u ra1u added the bug label Oct 23, 2021
@ra1u
Copy link
Owner

ra1u commented Oct 24, 2021

I have reported this behavior at dart-sdk dart-lang/sdk#47538 and you can follow and contribute as we are learning what is going on.

@Caesar0
Copy link
Author

Caesar0 commented Oct 25, 2021

Thanks sir,Ancestral blessing, I hope it can be solved as soon as possible!😊

@ra1u
Copy link
Owner

ra1u commented Oct 31, 2021

There is simple patch available for dart.
Let see how fast we can get this trough.

https://dart-review.googlesource.com/c/sdk/+/218700

ra1u added a commit that referenced this issue Nov 2, 2021
@ra1u
Copy link
Owner

ra1u commented Nov 2, 2021

We have got some response from Dart and there is workaround. One needs to close socket just when error is received.

This workaround is now implemented in master branch and will be released in next days.

Please test and report if you have issues.

@ra1u
Copy link
Owner

ra1u commented Nov 4, 2021

Fixed and released whit v2.2.0.

Thank you for your input.

@ra1u ra1u closed this as completed Nov 4, 2021
@Caesar0
Copy link
Author

Caesar0 commented Nov 9, 2021

Thanks sir,I tested it and it has been repaired.
Thank you for solving this problem in your busy schedule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants