Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

ConnectionStateChange DISCONNECTED #26

Open
SANCHEZSJD opened this issue Sep 30, 2020 · 2 comments
Open

ConnectionStateChange DISCONNECTED #26

SANCHEZSJD opened this issue Sep 30, 2020 · 2 comments

Comments

@SANCHEZSJD
Copy link

I have a view with a bottomNavigationBar, when I move between each tab, the Pusher connection changes to: DISCONNECTED. I only execute the action of "pusher.connect" in the initState of the view

@MisterJimson
Copy link
Contributor

Are you disconnecting at all? You may want to cache the pusher objects you receive somewhere outside of the UI layer so you are not constantly connecting and disconnecting.

@NTJ3
Copy link

NTJ3 commented Nov 6, 2020

i face same issue connection state is keep changing frequently after connecting pusher
i made singleton class for connection and i trigger connect inside initState,

import 'package:pusher_websocket_flutter/pusher.dart' as Pusher;

Pusher.PusherAuth pusherAuth = Pusher.PusherAuth(
        PusherUrls.kAuthEndpoint,
        headers: {
          PusherVariables.kChatApiHeaderKey: PusherVariables.kChatApiKey,
        },
      );
      Pusher.PusherOptions pusherOptions = new Pusher.PusherOptions(
        cluster: PusherVariables.kCluster,
        auth: pusherAuth,
        activityTimeout: 3000,
      );
      log.info('IN PUSHER INIT${pusherOptions.auth.endpoint}');
      Pusher.Pusher.init(
        PusherVariables.kPusherApiKey,
        pusherOptions,
        enableLogging: true,
      ).then((value) {
        this.isPusherAuthenticated = true;
        connectPusher();
      }).catchError((err) {
        log.info('ERROR IN PUSHER INIT');
        log.info(err.toString());
        throw err;
      });

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

No branches or pull requests

3 participants