pubnub / dart

PubNub Dart SDK
Other
27 stars 15 forks source link

When PAM enabled and subscribed with channelGroup throwing Exception RequestFailureException #77

Open Brinfotech1407 opened 2 years ago

Brinfotech1407 commented 2 years ago

Hello I have enabled PAM it works well when I am subscribing through channel Set. Also added retry logic before it's about to expire it works fine though with channel set, but when I am trying to subscribe through channel Group on first instance of it throwing me a following exception.

E/flutter (27374): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: RequestFailureException: request returned non-success status code: 403 E/flutter (27374): #0 new PubNubException (package:pubnub/src/core/exceptions.dart:9:47) E/flutter (27374): #1 new RequestFailureException (package:pubnub/src/core/net/exceptions.dart:28:9) E/flutter (27374): #2 RequestHandler.response (package:pubnub/src/networking/request_handler/io.dart:123:15) E/flutter (27374): <asynchronous suspension> E/flutter (27374): #3 Future.any.onValue (dart:async/future.dart) E/flutter (27374): <asynchronous suspension>

Following is my subscription code on client side.

_channelsSubscription ??= _client!.subscribe(withPresence: withPresence,channelGroups: _channelGroupsSet, );

And Following is my server side code for grantToken.

pubnub.grantToken( { ttl: ttl, resources: { groups: "UUID_cg01":{ read: true, manage: true, } }, );

can you help me here what i am doing wrong here

mohitpubnub commented 2 years ago

Hi @Brinfotech1407

Do you have channels inside mentioned channelGroups ? Possible reason for this error can be - subscribe request ultimately ends up with subscribing no channels (because channelGroup does not contain any member channels so it becomes empty subscription set)

Brinfotech1407 commented 2 years ago

@mohitpubnub Yes it have channels inside channelGroup

On Thu, Jan 6, 2022, 1:04 PM Mohit Tejani @.***> wrote:

Hi @Brinfotech1407 https://github.com/Brinfotech1407

Do you have channels inside mentioned channelGroups ? Possible reason for this error can be - subscribe request ultimately ends up with subscribing no channels (because channelGroup does not contain any member channels so it becomes empty subscription set)

— Reply to this email directly, view it on GitHub https://github.com/pubnub/dart/issues/77#issuecomment-1006344937, or unsubscribe https://github.com/notifications/unsubscribe-auth/APZMSVHXI7CIGWQDHLRCXQLUUVAXTANCNFSM5LLTY4WA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Brinfotech1407 commented 2 years ago

@mohitpubnub can a channel be in a two different channel group ?

Brinfotech1407 commented 2 years ago

image @mohitpubnub while we were debugging why at subscription via channel group throwing an exception we got to know that subscribe request is using v2/subscribe/ and we are using pubnub SDK ver 4.1.0. And at a time of Reading PAM documentation we got to know that PAM is using v3 so is it fine ?

mohitpubnub commented 2 years ago

@Brinfotech1407 If I assume at

_channelsSubscription ??= _client!.subscribe(withPresence: withPresence,channelGroups: _channelGroupsSet, );

withPresence = true, then It is trying to subscribe UUID_cg01 channelGroup withPresence

If it is the case then, It needs read permission on that channelGroup's presence as well. It means here UUID_cg01-pnpres read permission is required.

Wing-Li commented 6 months ago

Hi @Brinfotech1407

Do you have channels inside mentioned channelGroups ? Possible reason for this error can be - subscribe request ultimately ends up with subscribing no channels (because channelGroup does not contain any member channels so it becomes empty subscription set)

Does it mean that the message needs to be published first before it can be subscribed?