繁体   English   中英

Redis 3.0.6中的socket.io-redis获取尾随字节错误

[英]socket.io-redis getting trailing bytes error in redis 3.0.6

我使用phpredis将数据发送到node.js通过pubsub方法。 将node.js升级到稳定版4.2后,我从socket.io-redis模块中收到trailing byte错误。

的node.js

var pub = redis.createClient(2222, '127.0.0.1',{no_ready_check: true})

pub.auth(redisPassword);

var allsub = redis.createClient(2222, '127.0.0.1',{return_buffers: true,no_ready_check: true})

allsub.auth(redisPassword);

allsub.subscribe('somekey');

io.adapter(RedisStore({pubClient:pub,subClient:allsub}));

错误:

   Error: 256 trailing bytes
        at Object.decode (/usr/apps/js/node_modules/msgpack-js/msgpack.js:200:47)
        at Redis.onmessage (/usr/apps/js/node_modules/socket.io-redis/index.js:93:24)
        at emitTwo (events.js:92:20)
        at RedisClient.emit (events.js:172:7)
        at RedisClient.return_reply (/usr/apps/js/node_modules/redis/index.js:697:22)
        at ReplyParser.<anonymous> (/usr/apps/js/node_modules/redis/index.js:324:14)
        at emitOne (events.js:77:13)
        at ReplyParser.emit (events.js:169:7)
        at ReplyParser.send_reply (/usr/apps/js/node_modules/redis/lib/parser/javascript.js:302:10)
        at ReplyParser.execute (/usr/apps/js/node_modules/redis/lib/parser/javascript.js:213:22)
        at RedisClient.on_data (/usr/apps/js/node_modules/redis/index.js:550:27)
        at Socket.<anonymous> (/usr/apps/js/node_modules/redis/index.js:105:14)
        at emitOne (events.js:77:13)
        at Socket.emit (events.js:169:7)
        at readableAddChunk (_stream_readable.js:146:16)
        at Socket.Readable.push (_stream_readable.js:110:10)
        at TCP.onread (net.js:523:20)

为了找出问题,我将socket.io降级为1.36,但错误仍然存​​在。

我已遵循此线程中建议的解决方案,但它们不起作用。

1.添加return_buffers:对实例为true不起作用。

重新启动时将导致此警告:

[nodemon] restarting due to changes...
[nodemon] starting `node node.js`
listening on *:3000
[TypeError: input.split is not a function]

2.将依赖关系更改为上一篇文章中建议的msgpack-js-v5,但这种方法不起作用,如下所示:

socket.io-redis的/ index.js

var msgpack = require('msgpack-js-v5');

socket.io-Redis的/的package.json:

 "dependencies": {
 "async": "0.9.0",
 "debug": "2.2.0",
 "msgpack-js-v5": "*",
 "redis": "2.4.2",
 "socket.io-adapter": "github:automattic/socket.io-adapter#de5cba",
 "uid2": "0.0.3"
 },

真是无处可去。 谁能告诉我如何解决?

希望您的重做是:

var redis = require('redis');

RedisStore是:

var RedisStore= require(socket.io-redis);

还将主机端口添加到io.adapter中的RedisStore中,如下所示:

io.adapter(RedisStore({ pubClient: pub, subClient: allsub, host: '127.0.0.1', port: 222 }));

它对我有用...让我知道您是否有问题..

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM