直接通过redis-cli连接到我的twemproxy将正确地将我代理到redis而没有任何问题/断开连接。但是,当我使用node-redis连接到twemproxy时,我收到以下错误:
[Error: Redis connection gone from end event.]
跟踪如下:
Error: Ready check failed: Redis connection gone from end event.
at RedisClient.on_info_cmd (/home/vagrant/tests/write-tests/node_mo
dules/redis/index.js:368:35)
at Command.callback (/home/vagrant/tests/write-tests/node_modules/r
edis/index.js:418:14)
at RedisClient.flush_and_error (/home/vagrant/tests/write-tests/nod
e_modules/redis/index.js:160:29)
at RedisClient.connection_gone (/home/vagrant/tests/write-tests/nod
e_modules/redis/index.js:474:10)
at Socket.<anonymous> (/home/vagrant/tests/write-tests/node_modules
/redis/index.js:103:14)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:919:16
at process._tickCallback (node.js:419:13)
无论redis-server是否正在运行,都会发生此错误,所以我很确定它与node-redis和twemproxy的交互方式有关。或者根据具体情况不进行互动。
到底发生了什么?
我有一个简单的测试设置如下:
+------------------+
| +----+----+ |
| | r1 + r2 + |
| +----+----+ |
| | | |
| +---------+ |
| |twemproxy| |
| +---------+ |
| / | \ |
| +----+----+----+ |
| | aw | aw | aw | |
| +----+----+----+ |
+------------------+
aw = api worker
r1/r2 = redis instance
twemproxy = twemproxy
答案 0 :(得分:10)
经过一些挖掘,我意识到这是因为node_redis在默认情况下尝试在连接上调用“info”命令。
只需修改连接选项以包含no_ready_check: true
即可解决此问题并通过twemproxy强制连接。