Redis:奇怪的协议/网络错误 [英] Redis: weird protocol/network errors

查看:72
本文介绍了Redis:奇怪的协议/网络错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Redis 并使用 ezmobius 的 Redis gem[1] 从 Ruby 进行连接.

I'm running Redis and connecting from Ruby using ezmobius's Redis gem[1].

每隔一段时间(大约每天一次),由于 Redis 返回奇怪的结果,我的 Rails 应用程序会出现一系列异常.

Periodically (about once a day) I get a series of exceptions in my Rails app caused by Redis returning strange results.

它们通常由以下异常触发:

They are often triggered by an exception such at this:

Redis::ProtocolError: Protocol error, got '3' as initial reply byte                         

Redis::ProtocolError: Protocol error, got '9' as initial reply byte                      

有时

Errno::EAGAIN: Resource temporarily unavailable - Timeout reading from the socket

通常需要重启我的 Rails 服务器来解决连接问题.我正在运行 Fedora Core 8、Rails 2.3.8、Redis gem 2.0.3.我已经安装了 system_timer gem.有人知道如何阻止这些错误吗?

It usually requires a restart of my Rails servers to clear up the connection problem. I'm running Fedora Core 8, Rails 2.3.8, Redis gem 2.0.3. I've got the system_timer gem installed. Anybody got any ideas how I can stop these errors?

[1]Redis gem

推荐答案

我有一个与

Errno::EAGAIN: Resource temporarily unavailable - Timeout reading from the socket

事实证明,我的 redis-server 连接超时设置为 300 秒.5 分钟后,redis 正在终止与我的工作人员的连接,他们正在记录上述错误.

Turns out, my redis-server had a timeout set to 300 seconds on connections. After 5 minutes, redis was killing the connection to my workers and they were logging the error above.

如果您的套接字超时每 x 秒发生一次,那么无疑是 redis 杀死了您的空闲"连接!

If your socket timeouts are happening every x seconds, its no doubt redis killing your 'idle' connection!

这篇关于Redis:奇怪的协议/网络错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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