Skip to content

No Result when Access Manager Error Occurs #101

@kromenak

Description

@kromenak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions