using redis stack exchange version 8.0.5 and .net 6 we are seeing a lot of exceptions "Unable to read data from the transport connection. An existing connection was forcibly closed by the remote host"

Birnholtz, More 0 Reputation points
2023-05-07T21:29:24.6266667+00:00

Hi,
we are using StackExchange redis (version 8.0.5) on a .net 6 service that is deployed in cloud foundry.
We are seeing lots (and I mean lots) of exceptions of type "Unable to read data from the transport connection. An existing connection was forcibly closed by the remote host" (but values are being cached) and I would love your help to see what we might be doing wrong in the redis configuration and how we might fix this issue and improve.

Looking in redis insights, I see 254 client connections but very low utilization.
I ran client list command to get some more data and am providing a snapshot of some of it below here.
I can see the age of the connections is very long, days even. Is this normal/ expected?
Also see the idle time is very low..

In addition I ran the "config get timeout" command and saw that the value is 0, which means that the server does not close idle connections. I read somewhere that this is the default behavior and is ok, but would like your input on what the BKM is.

also attaching our configuration, set in the code.

from what I read i think the issue is that because connections are open for so long, at some point we have network failure which cause this. But I could really use your expertise.
Is this the issue or something else? if this is the issue, then how do we solve it? with keepAlive? which setting the timeout of idle connections (when client connection is idle for some time should we tell server to close it)?
Is there anything else your are seeing in the configuration or data we provided that is not following the standards or BKMs?
Thanks !

redis cofiguration set in c#:
User's image

from redis insights:
User's image

client list (snapshot of some lines):
User's image

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,841 questions
Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
251 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 15,301 Reputation points
    2023-05-08T09:49:36.4133333+00:00

    Hi Birnholtz, More,

    Welcome to Microsoft Q&A forum and thanks for using Azure Services.

    As I understand, you are getting error: Unable to read data from the transport connection. An existing connection was forcibly closed by the remote host in Azure Cache for Redis.

    As mentioned in the question you have set timeouts. I would suggest you to go through official blogpost on Azure Redis Timeouts - Client Side Issues which has detailed explanation of different reasons and solutions/mitigations.

    Other useful links:

    https://github.com/lettuce-io/lettuce-core/issues/1776

    https://stackoverflow.com/questions/13128363/redis-ioexception-existing-connection-forcibly-closed-by-remote-host-using-se

    https://community.progress.com/s/article/Azure-Redis-SSL-protocol-change-to-TLS-1-2

    Please take a look and let us know if this helps. If not, we will further investigate into the issue.

    Thanks in advance.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.