moontreeapp / moontree

Primary Mono Repo
6 stars 5 forks source link

connection lost #474

Closed lastmeta closed 2 years ago

lastmeta commented 2 years ago

Describe The Bug

sometimes if the app has been open for a while, like more than 5 minutes and you got to perform an action on the client it'll error, saying the client has no connection anymore.

Log Output

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: The client closed with pending request "blockchain.transaction.broadcast".
E/flutter ( 6823):
E/flutter ( 6823): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Connection reset by peer (OS Error: Connection reset by peer, errno = 104), address = 143.198.142.78, port = 47614

Additional Context

we need to make sure we know when we're disconnected from the server - I think the server disconnects us then we don't get the message or something, so we don't reconnect.

Even though these endpoints don't need an active connection we might as well push everything through that connection because we want to maintain it for the subscriptions, I suppose.

Screenshots

image

lastmeta commented 2 years ago
          /// this isn't getting executed when the peer closes the client:
          unawaited(client.peer.done.then((value) async {
            streams.client.connected.add(ConnectionStatus.disconnected);
            print('streams.app.active.value ${streams.app.active.value}');
            if (streams.app.active.value) {
              streams.client.client.add(null);
            }
lastmeta commented 2 years ago

I think the services.client.scope fixes this as long as we use it.