diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 22dd36256..eb176e6e7 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -8,6 +8,7 @@ Current package versions: ## Unreleased +- Fix [#2679](https://github.com/StackExchange/StackExchange.Redis/issues/2679) - blocking call in long-running connects ([#2680 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2680)) - Support async cancellation of `SCAN` enumeration ([#2911 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2911)) - Add `XTRIM MINID` support ([#2842 by kijanawoodard](https://github.com/StackExchange/StackExchange.Redis/pull/2842)) - Add new CE 8.2 stream support - `XDELEX`, `XACKDEL`, `{XADD|XTRIM} [KEEPREF|DELREF|ACKED]` ([#2912 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2912)) diff --git a/src/StackExchange.Redis/ConnectionMultiplexer.cs b/src/StackExchange.Redis/ConnectionMultiplexer.cs index de3e8d92e..146f7d2d3 100644 --- a/src/StackExchange.Redis/ConnectionMultiplexer.cs +++ b/src/StackExchange.Redis/ConnectionMultiplexer.cs @@ -681,8 +681,17 @@ private static ConnectionMultiplexer ConnectImpl(ConfigurationOptions configurat // note that task has timeouts internally, so it might take *just over* the regular timeout var task = muxer.ReconfigureAsync(first: true, reconfigureAll: false, log, null, "connect"); - if (!task.Wait(muxer.SyncConnectTimeout(true))) + if (task.Wait(muxer.SyncConnectTimeout(true))) { + // completed promptly - we can check the outcome; hard failures + // (such as password problems) should be reported promptly - it + // won't magically start working + if (!task.Result) throw ExceptionFactory.UnableToConnect(muxer, muxer.failureMessage); + } + else + { + // incomplete - most likely slow initial connection; optionally + // allow a soft failure mode task.ObserveErrors(); if (muxer.RawConfig.AbortOnConnectFail) { @@ -696,7 +705,6 @@ private static ConnectionMultiplexer ConnectImpl(ConfigurationOptions configurat } } - if (!task.Result) throw ExceptionFactory.UnableToConnect(muxer, muxer.failureMessage); killMe = null; Interlocked.Increment(ref muxer._connectCompletedCount);