pusher/pusher-channels-flutter

iOS app in foreground and network issue.

Closed this issue · 5 comments

Hi, there seems to be an issue with iOS. When you minimize the app and after a few secconds it throws some error messages and sometimes but not always when you bring it back to foreground it stops receiving messages and trying to reconnect.

flutter: RoomSubscribed
flutter: Room connected
flutter: state: RECONNECTING
flutter: state: CONNECTED
flutter: RoomSubscribed
[connection] nw_read_request_report [C1] Receive failed with error "Operation timed out"
flutter: state: DISCONNECTED
flutter: state: RECONNECTING
flutter: state: CONNECTING
flutter: state: CONNECTED
flutter: RoomSubscribed
dnssd_clientstub read_all(13) DEFUNCT
[VERBOSE-2:FlutterObservatoryPublisher.mm(130)] Could not register as server for FlutterObservatoryPublisher. Check your network settings and relaunch the application.
dnssd_clientstub read_all(15) DEFUNCT
[VERBOSE-2:FlutterObservatoryPublisher.mm(130)] Could not register as server for FlutterObservatoryPublisher. Check your network settings and relaunch the application.
[connection] nw_read_request_report [C4] Receive failed with error "Software caused connection abort"
[connection] nw_read_request_report [C4] Receive failed with error "Software caused connection abort"
flutter: state: DISCONNECTED
flutter: state: RECONNECTING
flutter: state: CONNECTING
flutter: state: DISCONNECTED
flutter: state: RECONNECTING
flutter: state: CONNECTED
dnssd_clientstub write_all(18) DEFUNCT
dnssd_clientstub deliver_request ERROR: write_all(18, 81 bytes) failed
dnssd_clientstub write_all(18) DEFUNCT
  • The device is real not emulator
pusher = PusherChannelsFlutter.getInstance();
    await pusher.init(
      apiKey: _pusherKey,
      cluster: 'eu',
      logToConsole: true,
      onAuthorizer: _onAuthorizer,
      onConnectionStateChange: (state, s) {
        print('state: $state');
      },
      onError: (message, code, error) {
        print('message: $message');
        print('code: $code');
        print('error: $error');
      },
    );
    ```
I remeber a few years ago Firestore had the same issue.

Yeah, same problem here.

I tried manually disconnecting in AppLifecycleState.paused and reconnecting on AppLifecycleState.resumed, but many times the connection does not successfully close. The connectionState transitions from CONNECTED to DISCONNECTING but it does not transition from DISCONNECTING to DISCONNECTED. Every time this happens, I get the DEFUNCT when reopening the app.

On a successful disconnect (where the connectionState transitions all the way to DISCONNECTED) everything works fine when reconnecting in AppLifecycleState.resumed (invoking connect).

This is only a problem on iOS though, never had a disconnect fail on Android.

Now I try to disconnect in AppLifecycleState.paused and just always completely re-init in AppLifecycleState.resumed. That ensures that I always receive messages when reopening the app. Sometimes though, I receive a DISCONNECTED state but the app still receives messages.

Maybe due to reinitialising?
Maybe its a different instance disconnecting?
I don't know, but for the time being it works reliably.

We have a new v2.2.0 version that also uses our newer PusherSwift 10.1.4, can you give it a try?

I could not reproduce this bug with v2.2.0 in debug mode. Looks really promising, will report back after some real world tests.

Thanks!

After testing for a couple of days it looks like 2.2.0 fixed it for me.

Thank you!

Thanks for the feedback that the new version works better. I will close this ticket.