Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformException(TRIGGER_ERROR, Cannot trigger event client-my-tracking because channel private-ride-138 is in SUBSCRIBE_SENT state #49

Open
KBRR11 opened this issue Feb 21, 2022 · 0 comments
Assignees

Comments

@KBRR11
Copy link

KBRR11 commented Feb 21, 2022

Hello, I am making a delivery application in which the delivery man must constantly broadcast his location, everything is fine until the delivery man goes through areas where he does not have a very good signal for mobile data and pusher stops sending events, for which I have this error:

PlatformException(TRIGGER_ERROR, Cannot trigger event client-my-tracking because channel private-ride-138 is in SUBSCRIBE_SENT state, java.lang.IllegalStateException: Cannot trigger event client-my-tracking because channel private-ride-138 is in SUBSCRIBE_SENT state at com.pusher.client.channel.impl.PrivateChannelImpl.trigger(PrivateChannelImpl.java:48) at com.github.chinloyal.pusher_client.pusher.PusherService.trigger(PusherService.kt:278) at com.github.chinloyal.pusher_client.pusher.PusherService.access$trigger(PusherService.kt:30) at com.github.chinloyal.pusher_client.pusher.PusherService$register$1.onMethodCall(PusherService.kt:60) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178) at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206) at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD

My question here is... how can I know the status of a channel? because in the documentation it only shows how to know the state of the pusher with pusher.onConnectionStateChange(), but this takes about 30 to 40 seconds to show in an emulator, or how can I know if my events are being sent correctly?

For example, I have this: when the distributor starts to move, I capture its location every 10 meters, which is why I ask about the connection status of the pusher:

`conectarPusher(userId) async {
await pusher.connect();
channel = pusher.subscribe('private-ride-$userId')
pusher.onConnectionStateChange((state) async {
pusherConnection = state?.currentState ?? 'DISCONNECTED';
print(
"--- CAMBIO DE ESTADO de: ${state?.previousState} a -> ${state?.currentState}");

      if (state?.currentState == 'CONNECTED') {
        canSendEvents = true;
      } else {
        canSendEvents = false;
      }
    });

}`

BackgroundLocation.getLocationUpdates((position) async { final positionRepartidor = { "latitude": position.latitude, "longitude": position.longitude }; if (canSendEvents) { channel.trigger('client-my-tracking', jsonEncode(positionRepartidor)); } else { print("No envio nada porque el pusher está desconectado"); } });

and this one is my Pusher options configuration:
PusherClient pusher = PusherClient( Enviroments.appKeyPusher, PusherOptions( cluster: 'us2', encrypted: true, auth: PusherAuth(Enviroments.authEndPointPusher)), autoConnect: false);

please 🙏 what should be the correct way to check the status of the channel, the pusher and the correct sending of events

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

No branches or pull requests

2 participants