Websocket cleanly disconnects on Flutter web

186

To check if there is an issue with Pusher you may need to get in touch with them over at https://support.pusher.com/hc/en-us/requests/new.

Share:
186
user3808307
Author by

user3808307

Updated on December 22, 2022

Comments

  • user3808307
    user3808307 over 1 year

    We have a connection to a pusher websocket. We are sending ping message every 40 seconds.

    Library being used: https://pub.dev/packages/web_socket_channel

    We are logging into console when a disconnection happens.

    It takes account on the onDone event here

    _subscription = _channel!.stream.listen(
        (e) => _handlePusherEvent(e, id),
        onDone: () => _onDone(message: 'onDone'), // Erratic clean disconnection here
        onError: (e) => _onWebsocketError(e),
    );
    
    
    void _onDone({required String message}) {
      print(message);
    }
    

    The behavior is erratic, sometimes it is done after 7 hours, sometimes it only takes minutes. We are logging ping and pong messages. The ping message log precedes the onDone event, so it is not being closed due to no ping message being sent.

    Is this some issue on pusher side?

    Thank you