Package / version: Abp.RedisCache 11.0.0 and 11.1.0 (net10.0)
Description
When Redis is enabled with Configuration.Caching.UseRedis(...), IOnlineClientManager.GetAllClientsAsync() returns the right number of clients, but every one has all properties null (ConnectionId, IpAddress, TenantId, UserId, ConnectTime, …).
TryGetAsync, GetAllByUserIdAsync and TryRemoveAsync on the same store return correct data.
Steps to reproduce
- Enable Redis caching with Configuration.Caching.UseRedis(...), which registers RedisOnlineClientStore as IOnlineClientStore.
- Connect one or more SignalR clients so they are stored in the {OnlineClientsStoreKey}.Clients hash.
- Call IOnlineClientManager.GetAllClientsAsync().
Expected: each IOnlineClient has the values stored in Redis. Actual: each IOnlineClient has null or default values for every property.
Root cause In src/Abp.RedisCache/Runtime/Caching/Redis/RealTime/RedisOnlineClientStore.cs, GetAllAsync serializes the RedisValue struct itself rather than reading the JSON string stored in it:
public async Task<IReadOnlyList<IOnlineClient>> GetAllAsync() { return (await GetDatabase().HashGetAllAsync(_clientStoreKey).ConfigureAwait(false)) .Select(entry => JsonSerializer.Deserialize<OnlineClient>(entry.Value.ToJsonString())) .Cast<IOnlineClient>() .ToImmutableList(); } entry.Value.ToJsonString() produces JSON describing the RedisValue struct's own properties. Deserializing that into OnlineClient matches none of its properties, so every field stays null.
The other methods in the same class read the value correctly with .ToString(), for example in TryGetAsync:
var client = JsonSerializer.Deserialize<OnlineClient>(clientValue.ToString());
1 Answer(s)
-
0
Hi,
Thank you for your report, we have fixed this bug and merged the pull request https://github.com/aspnetzero/aspnetboilerplate/pull/39. It will be in the next release of ASP.NET Boilerplate. In the meantime, you can replace
RedisOnlineClientStore.cswith your own implementation.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)
