Can't reconnect to Redis until application is restarted
davidjrh opened this issue · 1 comments
Check https://gist.github.com/JonCole/36ba6f60c274e89014dd
A DNN instance is using StackExchange.Redis to connect to their Redis instance and everything is working fine until suddenly exceptions like this start happening.
It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail.
at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func`1 multiplexerFactory, TextWriter log)
at MyApp.Web.Redis.StackExchangeClientConnection..ctor(ProviderConfiguration configuration)
at MyApp.Web.Data.GetInventoryData()
Most often this is caused by some type of network blip that occurs where connectivity is briefly lost between the client and the server. StackExchange.Redis has a setting named AbortOnConnectFail that controls how it handles connectivity errors like this. The default value for this setting is "True", meaning that it will not reconnect automatically in some cases (like the one I described above).
Setting AbortOnConnectFail to false will tell StackExchange.Redis to automatically reconnect in the background when the connection is lost for any reason.
Fix tested, the client reconnects when having the connection available. This setting can be overriden on the connection string by adding ",abortConnect=true" to have the previous behavior.