Redis Docker Container Error ArgumentException: No endpoints specified (Parameter 'configuration')


Question: How do you solve the error that comes when you are trying to cache an object to Redis and the error says "ArgumentException: No endpoints specified (Parameter 'configuration')".

Login to See the Rest of the Answer

Answer:
When working with Redis Docker Container in Asp.Net 5 Application, in order to connect to the external Redis Cache Server you will need to provide the Configuration Settings. The ConfigurationOptions requires the Endpoints to have two parameters, one is for the IP Address (Just IP Address, do not include HTTP or HTTPS) and the other one is for the port. Make sure you put all these settings in the appsettings.json and use the IConfiguration Interface to get the values from the file.

See the code below:

            services.AddDistributedMemoryCache();
            services.AddStackExchangeRedisCache(options =>
            {
            options.InstanceName = _configuration.GetValue<string>("NameOfInstanceHere");
            options.ConfigurationOptions = new ConfigurationOptions()
            {
                EndPoints = { { _configuration.GetValue<string>("SettingsBlock:ConnectionString"), PortNumberComesInHere } },
                ConnectRetry = 2,
                ReconnectRetryPolicy = new LinearRetry(10),
                //Ssl = true,
                //AbortOnConnectFail = false,
                ConnectTimeout = 5000,
                //SyncTimeout = 1000,
                DefaultDatabase = 0,
                 Password = _configuration.GetValue<string>("Password")
            };



        });




If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2023 - ErnesTech LLC- Privacy