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

No Result when Access Manager Error Occurs #101

Open
kromenak opened this issue Jan 25, 2024 · 0 comments
Open

No Result when Access Manager Error Occurs #101

kromenak opened this issue Jan 25, 2024 · 0 comments

Comments

@kromenak
Copy link

Hello, while implementing the latest v7.x SDK, I noticed that I don't seem to get callbacks/results for operations if they fail due to an Access Manager issue (such as if Access Control is enabled, but no auth token or an invalid auth token was provided).

For example, let's say I initialize the Pubnub SDK and then try to get a channel group occupancy. I have this code:

PNConfiguration pnConfiguration = new PNConfiguration(new UserId(userId));
pnConfiguration.SubscribeKey = subKey;
pnConfiguration.PublishKey = pubKey;
pnConfiguration.Secure = true;

pubnub = new Pubnub(pnConfiguration);
pubnub.AddListener(new SubscribeCallbackExt(OnMessageResult, OnPresenceResult, OnStatusEvent));

//pubnub.SetAuthToken(authToken); // commented out to demonstrate the problem

pubnub.HereNow().ChannelGroups(new string[] { "someChannelGroupName" }).IncludeState(false).IncludeUUIDs(false)
                .Execute(new PNHereNowResultEx((result, status) => {
                        if(status.Error)
                        {
                            OutputErrorInfo(status);
                        }
                        else
                        {
                            // Process data as needed
                        }
                }));

The problem is that the callback provided to "Execute" doesn't ever fire if you don't provide a valid auth token. I think the expected behavior is that the callback is fired, but the status.Error boolean would be true, and any other error message fields would be populated.

This is also a problem for operations that don't explicitly take a callback in their Execute() functions. For example, when subscribing to a channel, the "OnStatusEvent" callback is never executed when this issue occurs, even though (again) I'd expect it to be called with the status.Error to be set to true with any other error info.

If I enable PubNub's verbose logging to a file, I see that the system appears to be detecting that these calls are failing due to the Access Manager, but then I never receive callbacks so my code knows that these calls failed:

DateTime 01/25/2024 13:04:31, JSON= {"message": "Forbidden", "payload": {"channels": ["channelName"]}, "error": true, "service": "Access Manager", "status": 403}
 for request=https://ps.pndsn.com/v2/subscribe/sub-key/channel-name/0?heartbeat=300&pnsdk=UNITYCSharp6.19.4.0&requestid=384018d7-714f-4bf6-ad2a-0e9b01352965&tt=0&uuid=someUUID

DateTime 01/25/2024 13:04:31, Got HttpResponseMessage for https://ps.pndsn.com/v2/presence/sub_key/sub-key/channel/,?channel-group=some-channel-group&disable_uuids=1&pnsdk=UNITYCSharp6.19.4.0&requestid=916b4715-6a9f-4b3a-889b-797c39da9f37&state=0&uuid=someUUID
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

1 participant