Jeff Gabhart - 27 - Dec 10, 2014

As part of upgrading to v4, I needed to update redis from 2.4 to at least 2.6 due to what seemed like breaking changes. That’s fine except now I get intermittent connection errors. It will work for a while but then throw “A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond”. 
Do you have any advice on how I can better track down what is happening? I know about TrackingRedisClientsManager but that doesn’t seem to provide any useful information.
I have redis hosted on ubuntu 12 in an azure virtual machine. I’ve found many questions that sound similiar but it feels like no one has any idea what is really happening. 
http://stackoverflow.com/questions/22509232/servicestack-redis-client-and-receive-timeouts
http://stackoverflow.com/questions/20384052/servicestack-redis-unable-to-connect-sport
http://stackoverflow.com/questions/18963809/how-best-to-manage-redis-connections-using-servicestack
http://stackoverflow.com/questions/13128363/redis-ioexception-existing-connection-forcibly-closed-by-remote-host-using-se

Jeff Gabhart:

Also, I’m using today’s servicestack release and registered with 

.Register<IRedisClientsManager>(new RedisManagerPool(redis));

Sounds like the TCP Connection is dropping as those are underlying .NET Socket exceptions being thrown. From the exception message it appears that the Redis Client isn’t able to setup a TCP connection with the remote redis server, one way to confirm this is using WireShark to inspect the network packets to see if redis is returning the required SYN-ACK handshaking required to setup a TCP connection (more info at
http://www.inetdaemon.com/tutorials/internet/tcp/3-way_handshake.shtml)

One suggestion is to disable RDB persistence so it doesn’t fork
http://stackoverflow.com/a/20100427/85785 - more info about how improving and troubleshooting latency issues are published on: http://redis.io/topics/latency

E.g. 2.8.13 includes a latency monitoring feature where you can view logged latency events: http://redis.io/topics/latency-monitor

Jeff Gabhart:

I’m definitely not a wireshark expert but it looks like the connection is established fine. I can see that my connection on port 3284 (for example) worked for a while, but then after waiting about eight minutes and refresh my page, I see port 3284 used for [PSH,ACK] which contains the iauthsession key then five retransmissions of that packet and finally a [RST,ACK] which then gives me the yellow screen containing my “connection attempt failed” message. I don’t know if any of this is helpful :slight_smile:

Jeff Gabhart:

After about thirty minutes of monitoring, I can see some quits being sent which also result in retransmissions and finally [RST,ACK]'s

Jeff Gabhart:

And that might be IIS falling asleep, but it still shows that those pooled connections don’t seem to be usable any more.

Can you try switching back to the PooledRedisClientManager to see if it helps?

Jeff Gabhart:

Tried PooledRedisClientManager without additional options (only host and auth). It seems to create a lot more connections, waiting about five minutes, and I can see it try to send a get for the iauthsession using the lowest port number (I’m guessing it’s the first connection) and it ends up with five retransmissions and finally a reset that throws the same error.

Ok thx for the update. One thing to look at is to make sure the IdleTimeOutSecs is less than timeout in redis.conf. It can be configured on the Connection String.

Jeff Gabhart:

I connected to an azure redis instance and noticed in wireshark that they send tcp keep-alive every 15 seconds. I updated by redis server tcp-keepalive config and it seems to be smooth now… maybe yay?

that’s like a TCP heartbeat to keep the connection alive, so yeah hopefully!