mfeckie/phoenix_wings

StreamSink is closed

Closed this issue · 3 comments

Hi,

I get this error in flutter when device goes in bad network state

Unhandled Exception: Bad state: StreamSink is closed
#0      _StreamSinkImpl.add (dart:_http/http_impl.dart:536:7)
#1      _WebSocketImpl.add (dart:_http/websocket_impl.dart:1213:11)
#2      PhoenixIoConnection.send 
package:phoenix_wings/src/phoenix_io_connection.dart:37
#3      PhoenixSocket.push.<anonymous closure> 
package:phoenix_wings/src/phoenix_socket.dart:221
#4      PhoenixSocket.push 
package:phoenix_wings/src/phoenix_socket.dart:225
#5      PhoenixSocket.sendHeartbeat 
package:phoenix_wings/src/phoenix_socket.dart:214

There is also a piece of custom logic behind, maybe you can suggest what am I doing wrong

    connectivity = new Connectivity();
    final connRes = await connectivity.checkConnectivity();

    connectivity.onConnectivityChanged.listen((ConnectivityResult result) {
      if (result == ConnectivityResult.none) {
        _socket.disconnect();
        onConnectionChange.value = false;
      } else if (!_socket.isConnected) {
        _socket.connect();
        onConnectionChange.value = true;
      }
    });

Is this still an issue?

Should be fixed in 0.2.1