在Azure中的VM使用Redis的Booksleeve客户端时,Redis的连接错误 [英] Redis connection errors when using Booksleeve Redis client in Azure VM

查看:187
本文介绍了在Azure中的VM使用Redis的Booksleeve客户端时,Redis的连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始举办的新的Azure虚拟机我的一个辅助项目。该应用程序使用Redis的作为内存缓存。一切工作正常在我的本地环境,但现在,我已经感动code天青我看到一些奇怪的例外出来Booksleeve的。

I've recently started hosting a side project of mine on the new Azure VMs. The app uses Redis as an in-memory cache. Everything was working fine in my local environment but now that I've moved the code to Azure I'm seeing some weird exceptions coming out of Booksleeve.

当应用程序第一次激发了一切工作正常。然而,约5-10分钟不活动后的应用程序的下一个请求遇到网络异常(我的工作是正确的,现在不要对我确切的错误信息,所以我会张贴当我回家,如果人们认为他们是有密切关系的讨论)这将导致内部的MessageQueue关闭,这将导致每个后续排队()抛出异常(队列已关闭)。

When the app first fires up everything works fine. However, after about 5-10 minutes of inactivity the next request to the app experiences a network exception (I'm at work right now and don't have the exact error messages on me, so I will post them when I get home if people think they're germane to the discussion) This causes the internal MessageQueue to close, which results in every subsequent Enqueue() throwing an exception ("The Queue Is Closed").

所以经过一些谷歌上搜索,我发现这个职位的SO:<一href=\"http://stackoverflow.com/questions/8645953/maintaining-an-open-redis-connection-using-booksleeve\">Maintaining使用BookSleeve一个开放的Redis连接了解一个DIY连接管理器。我当然可以实现类似的东西,如果这是最好的行动路线。

So after some googling I found this SO post: Maintaining an open Redis connection using BookSleeve about a DIY connection manager. I can certainly implement something similar if that's the best course of action.

所以,问题:


  1. 这是正常的RedisConnection到一定时间后定期关闭?

  2. 我见过的 conn.SetKeepAlive()方法,但我已经尝试过许多不同的价值观和没有似乎有所作为。是否有更多的这个还是我找错了树?

  3. 是处理这种情况的最好方法?
  4. 上面的后连接管理理念
  5. 任何人都可以解释为什么在一个新的Azure虚拟机托管的Redis我的情况会导致此问题的任何额外的光?我还可以肯定,如果我跑我对Azure的VM Redis的地方environement我遇到此问题。

  1. Is it normal for the RedisConnection to close periodically after a certain amount of time?
  2. I've seen the conn.SetKeepAlive() method but I've tried many different values and none seem to make a difference. Is there more to this or am I barking up the wrong tree?
  3. Is the connection manager idea from the post above the best way to handle this scenario?
  4. Can anyone shed any additional light on why hosting my Redis instance in a new Azure VM causes this issue? I can also confirm that if I run my local environement against the Azure Redis VM I experience this issue.

就像我说的,如果它是不寻常的Redis的连接不活动死去,我将张贴堆栈跟踪和异常从我的日志,当我回家。

Like I said, if it's unusual for a Redis connection to die after inactivity, I will post the stack traces and exceptions from my logs when I get home.

谢谢!

更新
迪迪埃在这可能与该Azure的使用负载balanacer评论中指出:<一href=\"http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/12/windows-azure-load-balancer-timeout-details.aspx\">http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/12/windows-azure-load-balancer-timeout-details.aspx

假设是这样的话,这将是实现一个连接管理器,可以解释为这个愚蠢的问题的最好办法。我想我不应该创建工作权单位的连接?

Assuming that's the case, what would be the best way to implement a connection manager that could account for this goofy problem. I assume I shouldn't create a connection per unit of work right?

推荐答案

从其他的答案/评论,这听起来像这是蔚蓝的基础设施关闭插座看起来闲置造成的。您的可能的只是有一个计时器的地方,定期执行某种操作,但要注意,这是已经建成Booksleeve:当它连接时,它会检查Redis的连接超时是什么,并配置心跳从关闭套接字prevent Redis的。你也许能够背驮式这prevent蔚蓝关闭套接字太多。例如,在Redis的-CLI会话:

From other answers/comments, it sounds like this is caused by the azure infrastructure shutting down sockets that look idle. You could simply have a timer somewhere that performs some kind of operation periodically, but note that this is already built into Booksleeve: when it connects, it checks what the redis connection timeout is, and configures a heartbeat to prevent redis from closing the socket. You might be able to piggy-back this to prevent azure closing the socket too. For example, in a redis-cli session:

config set timeout 30

应该配置Redis的(飞,无需重启)有30秒的连接超时。然后Booksleeve应自动采取措施,确保有一个很快的心跳前30秒。需要注意的是,如果这是成功的,你也应该让此设置后,在下次重新启动也适用编辑配置文件。

should configure redis (on the fly, without having to restart) to have a 30 second connection timeout. Booksleeve should then automatically take steps to ensure that there is a heartbeat shortly before 30 seconds. Note that if this is successful, you should also edit your configuration file so that this setting applies after the next restart too.

这篇关于在Azure中的VM使用Redis的Booksleeve客户端时,Redis的连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆