I have used Redis version 2.6.66 and DotNet Core 6.0 in my project.
The prject works well in the local but after deploying it on cloud.digitalocean.com
I get an error.
How Can I solve it?
Error:
fail: API.Middleware.ExceptionMiddleware[0] No connection (requires writable - not eligible for replica) is active/available to service this operation: SETEX /api/products|pageIndex-1|pageSize-6|sort-name, mc: 1/1/0, mgr: 10 of 10 > StackExchange.Redis.RedisConnectionException: No connection (requires writable - not eligible for replica) is active/available to service this operation: SETEX /api/products|pageIndex-1|p> at StackExchange.Redis.ConnectionMultiplexer.ThrowFailed[T](TaskCompletionSource`1 source, Exception unthrownException) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1836 --- End of stack trace from previous location --- at Infrastructure.Services.ResponseCacheService.CacheResponseAsync(String cacheKey, Object response, TimeSpan timeToLive) in C:\Workspace\MainProjects\eshop\sigma-backend-dotnet\sigma> at API.Helpers.CachedAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) in C:\Workspace\MainProjects\eshop\sigma-backend-dotnet\sigma\API\He> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope,> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Obje> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boo> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at API.Middleware.ExceptionMiddleware.InvokeAsync(HttpContext context) in C:\Workspace\MainProjects\eshop\sigma-backend-dotnet\sigma\API\Middleware\ExceptionMiddleware.cs:line 47
docker-compose configuration:
services:
redis:
image: redis:latest
ports:
- 6379:6379
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis-data:/data
redis-commander:
image: rediscommander/redis-commander:latest
environment:
- REDIS_HOSTS=local:redis:6379
- HTTP_USER=XXX
- HTTP_PASSWORD=YYY
ports:
- 8081:8081
depends_on:
- redis
volumes:
redis-data:
Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<IConnectionMultiplexer>(c =>
{
var configuration = ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Redis"), true);
return ConnectionMultiplexer.Connect(configuration);
});

