【问题标题】:StackExchange.Redis failing to connect with Mono in Mac OS XStackExchange.Redis 在 Mac OS X 中无法与 Mono 连接
【发布时间】:2014-07-15 06:51:09
【问题描述】:

我正在尝试在 Mac OS X 中的 Mono 上运行一个非常简单的 Redis 客户端,使用以下选项:

var configOptions = new ConfigurationOptions() 
{
    EndPoints =
{
    { "localhost", 6379 },
},
ResolveDns = true,
KeepAlive = 180
};
StringWriter sw = new StringWriter();
ConnectionMultiplexer.Connect(configOptions, tw);

连接失败。这是跟踪:

localhost:6379,keepAlive=180,resolveDns=True

Using DNS to resolve 'localhost'...
'localhost' => 127.0.0.1
1 unique nodes specified
Requesting tie-break from 127.0.0.1:6379 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:01 to respond...
127.0.0.1:6379 faulted: UnableToResolvePhysicalConnection on PING
127.0.0.1:6379 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6379: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Connecting; sub: Connecting; not in use: DidNotRespond
127.0.0.1:6379: int ops=0, qu=0, qs=0, qc=1, wr=0, async=1, socks=2; sub ops=0, qu=0, qs=0, qc=0, wr=0, socks=1
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0 (0.00 ops/s; spans 10s)
Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago
Starting heartbeat...

我尝试过使用和不使用 ResolveDNS 并直接指定 IP 地址。也尝试了几个端口。服务器正在运行,可以通过 redis-cli 访问。

StackExchange.Redis 版本="1.0.289" targetFramework="net45"

Redis-64 2.8.9

更新

StackExchange.Redis version="1.0.297" targetFramework="net45",同样的问题但不同的日志

localhost:6666,keepAlive=180,resolveDns=True

Using DNS to resolve 'localhost'...
'localhost' => 127.0.0.1
1 unique nodes specified
Requesting tie-break from 127.0.0.1:6666 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:05 to respond...
127.0.0.1:6666 faulted: UnableToResolvePhysicalConnection on PING
127.0.0.1:6666 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6666: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Connecting; sub: Connecting; not in use: DidNotRespond
127.0.0.1:6666: int ops=0, qu=0, qs=0, qc=1, wr=0, async=1, socks=2; sub ops=0, qu=0, qs=0, qc=0, wr=0, socks=1
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0 (0.00 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 127.0.0.1:6666 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:05 to respond...
127.0.0.1:6666 returned, but incorrectly
127.0.0.1:6666 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6666: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Disconnected; sub: Connecting; not in use: DidNotRespond
127.0.0.1:6666: int ops=0, qu=0, qs=0, qc=1, wr=0, async=5, socks=3; sub ops=0, qu=0, qs=0, qc=0, wr=0, socks=2
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0 (0.00 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 127.0.0.1:6666 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:05 to respond...
127.0.0.1:6666 returned, but incorrectly
127.0.0.1:6666 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6666: Standalone v2.0.0, master; keep-alive: 00:03:00; int: Disconnected; sub: Connecting; not in use: DidNotRespond
127.0.0.1:6666: int ops=0, qu=0, qs=0, qc=1, wr=0, async=8, socks=4; sub ops=0, qu=0, qs=0, qc=0, wr=0, socks=3
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0 (0.00 ops/s; spans 10s)
Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago

【问题讨论】:

  • 我正在调查一些单独的连接失败报告 - 我希望这是相关的
  • 用 1.0.297 试过。似乎您已经更改了与重试逻辑相关的内容,但没有运气。

标签: c# mono redis stackexchange.redis


【解决方案1】:

正如其他人所说,StackExchange.Redis 在连接到 mono 上的服务器时遇到问题,您必须从源构建一个自定义程序集,以 Mono 为目标。 所以我使用 monobuild.bash 从库的 mono 构建创建了一个 nuget 包。您可以将它用作单声道上原始 StackExchange.Redis 的直接替代品。

https://www.nuget.org/packages/StackExchange.Redis.Mono/

由于我们在服务器应用程序中使用该包,我会定期更新它。

【讨论】:

  • 请注意 link-only answers 是不鼓励的,所以答案应该是寻找解决方案的终点(与另一个中途停留的参考相比,随着时间的推移往往会变得陈旧)。请考虑在此处添加独立的概要,并保留链接作为参考。
  • @kleopatra 该链接不是参考,它是我为能够在 Mono 上使用 StackExchange.Redis 而制作的一个包,并认为这对遇到此问题的任何人都有用。
  • 我对此表示赞成,因为它解决了我在 Mono 下的问题,而无需花费超过一分钟的时间。感谢@LordHippo 的工作
【解决方案2】:

我直接使用 nuget 包时遇到了同样的问题。我已经克隆了 StackExchange.Redis 存储库并使用包含的单声道 bash 命令创建了一个新 DLL:

./monobuild.bash

引用了生成的 DLL,它在 OSX 上使用您在问题上放置的确切代码完美运行。

【讨论】:

  • 我可以确认在 Mono 中重建 StackExchange.Redis 会有所帮助(我是在 Windows 上使用 Xamarin Studio 以本地 Mono 安装为目标的)
  • 我可以确认,我只需要对在 Ubuntu 14.4 下运行的应用程序执行相同操作即可。从 mono repo 构建,然后将 DLL 复制到项目构建中使用的 DLL 解决了这个问题。
  • 在 OSX 上使用这种方法仍然会出错。 StackExchange.Redis 下的测试似乎都通过了。但仍然得到“故障:UnableToResolvePhysicalConnection”
猜你喜欢
  • 1970-01-01
  • 2014-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-05
  • 1970-01-01
相关资源
最近更新 更多