I tried to call ConnectionMultiplexer.ConnectAsync
in a Blazor client-side component in the following way:
protected override async Task OnInitializedAsync()
{
var configuration = new ConfigurationOptions
{
AbortOnConnectFail = false,
ConnectTimeout = 3000,
SyncTimeout = 5000,
KeepAlive = 180,
EndPoints =
{
{
"localhost", 6379
}
}
};
await ConnectionMultiplexer.ConnectAsync(configuration);
await base.OnInitializedAsync();
}
This throws an exception:
children could not be evaluated
How Is it possible to use StackExchange.Redis
in a Blazor WebAssembly
app?
Edit:
I found a more verbose error message in the VS output:
Unhandled exception rendering component: Cannot start threads on this runtime.
System.NotSupportedException: Cannot start threads on this runtime. at (wrapper managed-to-native) System.Threading.Thread.Thread_internal(System.Threading.Thread,System.MulticastDelegate) at System.Threading.Thread.StartInternal (System.Object principal, System.Threading.StackCrawlMark& stackMark) <0x3b02590 + 0x00008> in :0 at System.Threading.Thread.Start (System.Threading.StackCrawlMark& stackMark) <0x3b02450 + 0x0004e> in :0 at System.Threading.Thread.Start (System.Object parameter) <0x3b022d0 + 0x0003a> in :0 at Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler.StartWorker (System.Int32 id) [0x0003a] in C:\Code\Pipelines.Sockets.Unofficial\src\Pipelines.Sockets.Unofficial\DedicatedThreadPoolPipeScheduler.cs:112 at Pipelines.Sockets.Unofficial.DedicatedThreadPoolPipeScheduler..ctor (System.String name, System.Int32 workerCount, System.Int32 useThreadPoolQueueLength, System.Threading.ThreadPriority priority) [0x00072] in C:\Code\Pipelines.Sockets.Unofficial\src\Pipelines.Sockets.Unofficial\DedicatedThreadPoolPipeScheduler.cs:74 at StackExchange.Redis.SocketManager..ctor (System.String name, System.Int32 workerCount, StackExchange.Redis.SocketManager+SocketManagerOptions options) [0x0006e] in //src/StackExchange.Redis/SocketManager.cs:98 at StackExchange.Redis.SocketManager..ctor (System.String name, System.Int32 workerCount, System.Boolean useHighPrioritySocketThreads) [0x00000] in //src/StackExchange.Redis/SocketManager.cs:44 at StackExchange.Redis.SocketManager.get_Shared () [0x0000c] in //src/StackExchange.Redis/SocketManager.cs:132 at StackExchange.Redis.ConnectionMultiplexer.OnCreateReaderWriter (StackExchange.Redis.ConfigurationOptions configuration) [0x00000] in //src/StackExchange.Redis/ConnectionMultiplexer.ReaderWriter.cs:9 at StackExchange.Redis.ConnectionMultiplexer..ctor (StackExchange.Redis.ConfigurationOptions configuration) [0x000d6] in //src/StackExchange.Redis/ConnectionMultiplexer.cs:1150 at StackExchange.Redis.ConnectionMultiplexer.CreateMultiplexer (System.Object configuration, StackExchange.Redis.ConnectionMultiplexer+LogProxy log, System.EventHandler`1[StackExchange.Redis.ConnectionFailedEventArgs]& connectHandler) [0x0000d] in //src/StackExchange.Redis/ConnectionMultiplexer.cs:957 at StackExchange.Redis.ConnectionMultiplexer.ConnectImplAsync (System.Object configuration, System.IO.TextWriter log) [0x0003a] in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:854 at Joker.BlazorApp.Sample.Pages.ProductsComponentBase.OnInitializedAsync () [0x0007c] in C:\Users\tomas.fabian\source\repos\Joker.BlazorApp.Sample\Joker.BlazorApp.Sample\Pages\ProductsComponentBase.cs:52 at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x37da140 + 0x0013a> in :0