[英]Error being thrown on reconnection after disconnection in node-redis client
I couldn't understand what's the reason for the SocketClosedUnexpectedlyError
error fired in the code below:我不明白下面代码中引发的SocketClosedUnexpectedlyError
错误的原因是什么:
const redisClient = require('redis').createClient();
redisClient.connect().then(function() {
return redisClient.disconnect();
})
.then(function() {
redisClient.connect();
});
If I wrap the second redisClient.connect()
call inside a setTimeout()
call, as shown below, the error seems to go away:如果我将第二个redisClient.connect()
调用包装在setTimeout()
调用中,如下所示,则错误似乎远离 go:
const redisClient = require('redis').createClient();
redisClient.connect().then(function() {
return redisClient.disconnect();
})
.then(function() {
setTimeout(function() {
redisClient.connect();
}, 0);
});
Can anyone please explain what's the reason for the error thrown above?谁能解释一下上面抛出错误的原因是什么? The documentation of @node-redis
isn't good enough to explain this. @node-redis
的文档不足以解释这一点。
It's a bug in node-redis v4...这是node-redis v4中的一个错误......
https://github.com/redis/node-redis/issues/1801 https://github.com/redis/node-redis/issues/1801
https://github.com/redis/node-redis/commit/74daee302338cf2fcc1bb48aeac02be828e0c6d7 https://github.com/redis/node-redis/commit/74daee302338cf2fcc1bb48aeac02be828e0c6d7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.