RedisConnectionException at each first Connect(), while redis-py and hiredis work fine
Hi Marc,
Version 1.0.289.0 (nuget, .net 4.0).
When I leave my workstation alone for five minutes, after calling Connect() I get a RedisConnectionException the first time. Immediately retrying does work with no delay at a 90% success rate. No info is written to the supplied TextWriter.
var oCli = ConnectionMultiplexer.Connect("srv-flux-01:14144", log);
Complete exception message:
An unhandled exception of type 'StackExchange.Redis.RedisConnectionException' occurred in StackExchange.Redis.dll
Additional information: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail
I connect from Win7 Pro X64 to Redis 2.8.9 (x64) on a Debian machine on our LAN (same subnet). No hardware firewalls in between, only Windows firewall. Redis connections from redis-py or RedisDesktopManager(which uses hiredis) never fail, and always connect within milliseconds.
I use a simple Windows Forms project, VS2013 Express, for testing. I use (and need) the .NET Framework 4 Client Profile.
Any ideas?
Kind regards, TW
@mgravell I have seen this issue 2 times during development and found this thread. I'm using a hostname in the connectionstring and after setting my DNS server to something non-existant I get this error everytime. Well, actually also sometimes a variation on it:
It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
and sometimes:
It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING
So sounds to me like a DNS hickup when I got this error 2 times during development.
Trying out Redis on Azure and also getting this intermittently -
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING at StackExchange.Redis.ConnectionMultiplexer
same issue here on windows server 2012, azure vm with subnet enabled, in iis hosted site.
Other clients, including telnet clients can connect to this Redis server, but my code fails very often. Redis Server version 2.8.17; StackExchange.Redis client version 1.0.333.
configurationOptions: 192.168.1.11:6387,keepAlive=180,allowAdmin=True logs: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail.
1 unique nodes specified Requesting tie-break from 192.168.1.11:6387 > __Booksleeve_TieBreak... Allowing endpoints 00:00:05 to respond... 192.168.1.11:6387 did not respond 192.168.1.11:6387 failed to nominate (WaitingForActivation) No masters detected 192.168.1.11:6387: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Connecting; sub: ConnectedEstablished, 1 active; not in use: DidNotRespond 192.168.1.11:6387: int ops=0, qu=4, qs=0, qc=0, wr=0, socks=1; sub ops=3, qu=0, qs=0, qc=0, wr=0, subs=1, sync=3, socks=1 Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0+3=3 (0.30 ops/s; spans 10s) Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago resetting failing connections to retry... retrying; attempts left: 2... 1 unique nodes specified Requesting tie-break from 192.168.1.11:6387 > __Booksleeve_TieBreak... Allowing endpoints 00:00:05 to respond... 192.168.1.11:6387 did not respond 192.168.1.11:6387 failed to nominate (WaitingForActivation) No masters detected 192.168.1.11:6387: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Connecting; sub: ConnectedEstablished, 1 active; not in use: DidNotRespond 192.168.1.11:6387: int ops=0, qu=2, qs=0, qc=0, wr=0, async=5, socks=2; sub ops=3, qu=0, qs=0, qc=0, wr=0, subs=1, sync=3, socks=1 Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0+3=3 (0.30 ops/s; spans 10s) Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago resetting failing connections to retry... retrying; attempts left: 1... 1 unique nodes specified Requesting tie-break from 192.168.1.11:6387 > __Booksleeve_TieBreak... Allowing endpoints 00:00:05 to respond... 192.168.1.11:6387 did not respond 192.168.1.11:6387 failed to nominate (WaitingForActivation) No masters detected 192.168.1.11:6387: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Connecting; sub: ConnectedEstablished, 1 active; not in use: DidNotRespond 192.168.1.11:6387: int ops=0, qu=2, qs=0, qc=0, wr=0, async=8, socks=3; sub ops=3, qu=0, qs=0, qc=0, wr=0, subs=1, sync=3, socks=1 Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0+3=3 (0.30 ops/s; spans 10s) Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago
I dont know writing it here will solve our poblem. Please add a "+1" to the same error: "It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING at StackExchange.Redis.ConnectionMultiplexer"
In my case, the call to Connect(...) fails if it is inside an async delegate. I found this by trying to connect from within Nito's AsyncContext.Run(async () => {}) method. Hope that helps someone else :-)
I'm getting that error again. The interesting thing is that some of my peer devs are working on the exact same setup and they do not experience this.
Any ideas?
BTW even trying to connect to a localhost redis doesn't work. Meanwhile redis-client connects instantly.
+1
Stackexchange.Redis: 1.0.316.0 (via nuget) Mono 3.12.0 ((detached/a813491) Connection String: "192.168.0.40:10001"
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING
at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl (System.Func`1<StackExchange.Redis.ConnectionMultiplexer>,System.IO.TextWriter) <IL 0x00096, 0x0031b>
at StackExchange.Redis.ConnectionMultiplexer.Connect (string,System.IO.TextWriter) <IL 0x0001a, 0x000e7>
Output of telnet:
telnet 192.168.0.40 10001
Trying 192.168.0.40...
Connected to 192.168.0.40.
Escape character is '^]'.
PING
+PONG
+1 I have a same error, venkatperi (only under latest mono in linux, under windows w/o mono - all is ok), log: faulted: UnableToResolvePhysicalConnection on PING
I'm seeing the same issue intermittently while connecting to an Azure Redis instance. From the Azure monitoring I only have ~40 connections open at any given time.
-Lee
This is happening to me too, I'm using StackExchange.Redis.StrongName ver. 1.0.394, oddly enough, I've noticed that if I use StackExchange.Redis ver. 1.0.394 everything works fine. (but I need StrongName because of RedisSessionStateProvider)
Has anyone found a definitive solution for the "No connection is available to service this operation: SETEX" issue? I am currently using RE.Redis 1.0.331 and am seeing the same thing in my WebAPI app running in IIS. I have yet to constantly reproduce this issue but when it does happen its always occurs after rebooting our server.
I have 5 servers talking to redis and redis is configured with 1 master and 3 slaves. When I get into this state, about 1 in 5 or so calls actually work and the rest give me the no connection error. Also, most of the time my servers have no issue spinning back up and calling redis. I see this after reboot only about 1 in 10 times. I am just starting to dive into solutions for this issue but wanted to verify if someone has tracked this to the route cause yet.
If you are using new Lazy<ConnectionMultiplexer>(initCode) manually or through a third party library (e.g SimpleInjector DI container) then the exception on creation is cached, and therefore you need to restart the web app to fix the issue again.
I'm currently experimenting by calling the following in my Cache manipulation methods (instead of using DI):
void EnsureConnection() {
if (_cacheClient != null)
return;
lock (_lock) {
if (_cacheClient != null)
return;
var connectionMultiplexer = ConnectionMultiplexer.Connect(Environments.RedisCacheConnectionString);
Thread.MemoryBarrier();
_cacheClient = connectionMultiplexer;
}
}
(Unsure at this time if the Multiplexer will automatically restore a connection if it was lost in the meantime, otherwise one could extend it with IsConnected check I suppose. But since I see a ConnectionRestored event i'm guessing it will handle it automatically).
Another option could be to launch the Connect initialization on an ASP initialize-once-per-recycle basis in a static field. Which should try and restart the app on failure.
We were experiencing the same issue on one of our installations and to resolve it I replaced the IP address of the Redis server with the hostname (as mentioned earlier in this thread). No idea why this happened as we have the same configuration on lots of machines and have never seen this issue before.
I am seeing this issue too. In my case, I have a unit test that spawns multiple threads. Each thread gets a multiplexer (the first thread in will initialize it). That first thread enters ConnectionMultiplexer.ConnectImpl(). In that method, there is this line of code:
var task = Factory.StartNew(() => { return muxer.ReconfigureAsync(true, false, log, null, "connect").Result; });
In normal scenarios, this always works. However, in my multithreaded test, the Task.Factory never ends up calling the inline lambda in the above code. So the task times out, and surfaces as the exception noted in the beginning of this issue. I'm looking at it now, but thought I'd just post to maybe shed some additional info.
Adding onto the above ... Calling connect the first way (below) produces the error, but calling the second way does not:
return ConnectionMultiplexer.Connect(options) return Task.Run(async () => await ConnectionMultiplexer.ConnectAsync(options, sw)).Result;
I changed my test to not launch threads via Task.Run ... Instead, I am now creating threads manually, and starting them. The issue goes away - I was depleting the thread pool (as noted earlier in this thread).
+1 - I'm seeing what looks like the same thing with 1.0.414. It happens only on app startup, and not every time, but almost every time. We're deploying with MSDeploy. I'm going to try adding a ConnectRetry value > 1 and using the Task.Run() method @smiket suggested.
Update: This is still occurring after trying all reasonable mitigations I could find in this thread.
@mgravell I can reproduce this fairly reliably - what can I get you to help you debug it further?
I encountered the same issue. I downloaded the Redis code and debugged from my side, I found the code that is causing issue for me.
When the code tries to connect, it starts a new task and waits for either complete or timeout. var task = Task.Factory.StartNew(() => muxer.ReconfigureAsync(true, false, log, null, "connect").Result);
In order to limit the number of parallel tasks my code can use, I created a TaskFactory and set the TaskScheduler as a limited concurrency level task scheduler. Somehow this task used the same TaskFactory (haven't figured out why) and all the threads were busy on something else, so the task was never scheduled and executed during waiting.
I am guessing most of the issues happened here is because the task was not executed or hasn't completed.
@mgravell , hope this helps.
@saixiaohui thanks for the insight! I think you're on to something. We're using a limited concurrency scheduler as well - and the call to create the multiplexer the first time and do the Connect() is actually within a spun-off task.
I ended up creating the multiplexer and doing the Connect() in the static ctor of the class that ultimately spawns off the threads using the LCS, and so far that seems to have solved it. However, i'm not calling it a success yet, since the issue was semi-intermittent.
1.0.481 version, i've got exactly same exception as started this thread subject.
"It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING"
did i missed something?
It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING