StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

Getting exception when trying to connect to Redis

Open petriceko opened this issue 10 years ago • 8 comments

Hi,

After update nuget package from 1.1.606 to 1.1.608, I am getting RedisConnectionException - It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. Code, that is throwing exception: ConnectionMultiplexer.Connect($"{server}:{port}"); Updated nuget works fine in Windows, I am getting error only in Linux - Target Framework Mono/.Net 4.5 Any Idea, what is the problem?

Thanks, Peter.

petriceko avatar Oct 26 '16 07:10 petriceko

Same results on same setup, works on 1.1.606, not on 1.1.608

danzar avatar Nov 03 '16 21:11 danzar

I encounterd the same problem. 1.1.608 does not work on Linux Mono/.Net 4.5.1. 1.1.606 works fine!

ganaware avatar Nov 15 '16 06:11 ganaware

Ran into the same issue with v1.2 (mono 4.6.1).

bgiftge avatar Feb 08 '17 18:02 bgiftge

TL;DR: I did some digging on this and made a workaround that you can find here: (use at your own risk) https://github.com/PathogenDavid/StackExchange.Redis/commit/e2dcded94f6f26685667f4b82887485270c6692f However, SSL is broken for me still, so if you use SSL you might still be stuck.

I am also having this issue, so I decided to do some digging. I will note that this seems to happen on all of 1.1.603, 1.1.606, and 1.2.0 It happens on Mono 4.6.2 on Windows, Ubuntu 64-bit, and Ubuntu armhf.

I've narrowed the issue down to Socket.BeginConnect completely failing under Mono. So I suspect this is a regression in Mono. If you call Socket.BeginConnect on Mono, your callback will never be called even if the socket is established (as observed on Wireshark. I did not dig into Mono yet.)

This can be observed in this minimal test program: https://gist.github.com/PathogenDavid/8e6b7a2d745feb63f22f2991c98eaaf3 Running under .NET, the program quickly connects and then exits. Under Mono, however, the program waits forever for the callback to be called.

As a quick workaround, I simply modified things to use Socket.Connect instead. https://github.com/PathogenDavid/StackExchange.Redis/commit/e2dcded94f6f26685667f4b82887485270c6692f The ideal solution is probably to get Mono fixed, but one possibility would be implementing our own asynchonous connecting.

Unfortunately, it seems SSL isn't working either. SslStream.AuthenticateAsClient simply never returns to PhysicalConnecttion.Connected.

Hopefully this helps point some people in the right direction!

PathogenDavid avatar Feb 13 '17 06:02 PathogenDavid

BTW, @NickCraver Shouldn't this issue have the Mono label?

PathogenDavid avatar Feb 13 '17 21:02 PathogenDavid

1.2.3 works fine with Mono 5.0.0 (Centos x86_64t, .Net 4.5.1).

ganaware avatar May 19 '17 09:05 ganaware

Are we good with 1.2.3 on Mono then? I'm not in a position to test here.

NickCraver avatar Sep 02 '17 02:09 NickCraver

Consolidating into #314 where we're tracking this.

NickCraver avatar May 28 '18 01:05 NickCraver