kuzzle
kuzzle copied to clipboard
core:realtime:user:unsubscribe:after doesn't report kuid
Hello,
Trying to use core:realtime:user:unsubscribe:after
to generate a side effect. I do need to access subscription.kuid
field, but when I refresh my browser page I don't have access to kuid which is null
. Whereas I'm supposed to have the kuid
.
Related code :
Create (This is OK, kuid is present)
https://github.com/kuzzleio/kuzzle/blob/96ac03b60c19aa60128117f8a59eba9ec1969c5b/lib/core/realtime/hotelClerk.ts#L290-L298
This is not OK (kuid missing in unsubscribe)
https://github.com/kuzzleio/kuzzle/blob/96ac03b60c19aa60128117f8a59eba9ec1969c5b/lib/core/realtime/hotelClerk.ts#L589-L615
kuzzle-application-server:dev: subscription: Subscription {
kuzzle-application-server:dev: connectionId: '1b07674b-579e-4156-af1b-7b962e35cae5',
kuzzle-application-server:dev: roomId: 'some_id',
kuzzle-application-server:dev: index: 'main',
kuzzle-application-server:dev: collection: 'presence',
kuzzle-application-server:dev: filters: undefined,
kuzzle-application-server:dev: kuid: null
kuzzle-application-server:dev: }
Hello @ScreamZ
From what I see, if you get the kuid to null instead of the value you need it is because Kuzzle has not been able to getKuidFromConnection. Maybe your sdk in your application isn't properly connected with the user upon refresh ? maybe your are calling the unsubscribe method to soon upon refresh ?
Are you able to make a small reproduction of the issue so we can work with that and check if it's really a bug ?
// backend side
global.kuzzle.on("core:realtime:user:subscribe:after", (data) => {
console.log("User subscribed to room", data);
});
global.kuzzle.on("core:realtime:user:unsubscribe:after", (data) => {
console.log("User unsubscribed from room", data);
});
// Front side of an application
const roomId = await this.$kuzzle.realtime.subscribe(
"toto",
"tata",
{},
(notification) => {
console.log("Received notification", notification);
}
);
console.log("Room ID", roomId);
await this.$kuzzle.realtime.unsubscribe(roomId);
I properly get the kuid in the response object of the event core:realtime:user:unsubscribe:after
like so
kuzzle | User unsubscribed from room {
kuzzle | requestContext: RequestContext {
kuzzle | 'token': null,
kuzzle | 'user': null,
kuzzle | 'connection': Connection {
kuzzle | 'id': 'a98ea515-5885-44ef-936b-904803031f3a',
kuzzle | 'protocol': null,
kuzzle | 'ips': [],
kuzzle | 'misc': {}
kuzzle | }
kuzzle | },
kuzzle | room: {
kuzzle | collection: 'tata',
kuzzle | id: 'e04221d9d78f8f8cc1594f217ad9c9f71a9e16952a237f24b19df9ec65ba12cf',
kuzzle | index: 'toto'
kuzzle | },
kuzzle | subscription: Subscription {
kuzzle | connectionId: 'a98ea515-5885-44ef-936b-904803031f3a',
kuzzle | roomId: 'e04221d9d78f8f8cc1594f217ad9c9f71a9e16952a237f24b19df9ec65ba12cf',
kuzzle | index: 'toto',
kuzzle | collection: 'tata',
kuzzle | filters: undefined,
kuzzle | kuid: 'admin'
kuzzle | }
kuzzle | }