gpt4 book ai didi

heroku - socket.io RedisStore 是否适用于 heroku?

转载 作者:可可西里 更新时间:2023-11-01 11:02:16 26 4
gpt4 key购买 nike

我似乎无法让 socket.io RedisStore 在 heroku 上工作。我能够连接到 RedisToGo,但是当我调用 new RedisStore() 时如果我没有向 RedisToGo 连接提供密码,我会得到错误,例如:Error: Ready check failed: ERR operation not permitted

我的配置:

var http = require('http')
, sio = require('socket.io')
, _ = require('lodash')
, port = process.env.PORT || 8000
, httpServer = http.createServer().listen(port)
, io = sio.listen(httpServer)
, RedisStore = sio.RedisStore
, organization = require('./controllers/organization')
, chat = require('./controllers/chat')
, group = require('./controllers/group')
, util = require('util');

var DEV = false;

if (DEV) {
var pub = require('redis').createClient()
, sub = require('redis').createClient()
, client = require('redis').createClient();
}
else {
var rtg = require("url").parse(process.env.REDISTOGO_URL);
var pub = require("redis").createClient(rtg.port, rtg.hostname);
pub.auth(rtg.auth.split(":")[1], function(err) { console.log('pub ERR: ' + util.inspect(err)); });


var sub = require("redis").createClient(rtg.port, rtg.hostname);
sub.auth(rtg.auth.split(":")[1], function(err) { console.log('sub ERR: ' + util.inspect(err)); });

var client = require("redis").createClient(rtg.port, rtg.hostname);
client.auth(rtg.auth.split(":")[1], function(err) { console.log('client ERR: ' + util.inspect(err)); });

}


io.configure(function() {
//create redis connection, set options

var opts = {host: '127.0.0.1', port: '6379'}
/******* PROBLEM HERE ******/
, redisStore = new RedisStore({redisPub: pub,
redisSub: sub,
redisClient: client});


//io.set('store', redisStore);
io.set('transports', ['xhr-polling']);
//io.set('close timeout', 30);
//io.set('hearbeat timeout', 28);
//io.set('hearbeat interval', 15);
io.set("polling duration", 10);
//io.set('log level', 0);


if (DEV) {
require('./lib/dev_static').static(io);
}
else {
require('./lib/prod_static').static(io);
}

});

io.sockets.on('connection', function(socket) {
etc ...

});

来自 Heroku 的错误日志:


2013-04-30T19:38:30.070457+00:00 heroku[web.1]: Starting process with command 'node app.js'
2013-04-30T19:38:30.917568+00:00 app[web.1]: info: socket.io started
2013-04-30T19:38:31.002714+00:00 app[web.1]: client ERR: null
2013-04-30T19:38:31.009598+00:00 app[web.1]:
2013-04-30T19:38:31.010050+00:00 app[web.1]: /app/node_modules/socket.io/node_modules/redis/index.js:506
2013-04-30T19:38:31.003255+00:00 app[web.1]: pub ERR: null
2013-04-30T19:38:31.001801+00:00 app[web.1]: sub ERR: null
2013-04-30T19:38:31.010729+00:00 app[web.1]: throw callback_err;
2013-04-30T19:38:31.011043+00:00 app[web.1]: ^
2013-04-30T19:38:31.015164+00:00 app[web.1]: at Command.callback (/app/node_modules/socket.io/node_modules/redis/index.js:367:14)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.return_error (/app/node_modules/socket.io/node_modules/redis/index.js:502:25)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.on_info_cmd (/app/node_modules/socket.io/node_modules/redis/index.js:319:35)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.send_error (/app/node_modules/socket.io/node_modules/redis/lib/parser/javascript.js:266:14)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/socket.io/node_modules/redis/index.js:79:14)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.on_data (/app/node_modules/socket.io/node_modules/redis/index.js:478:27)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.execute (/app/node_modules/socket.io/node_modules/redis/lib/parser/javascript.js:125:22)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.<anonymous> (/app/node_modules/socket.io/node_modules/redis/index.js:262:14)
2013-04-30T19:38:31.015164+00:00 app[web.1]: Error: Ready check failed: ERR operation not permitted
2013-04-30T19:38:31.015476+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.EventEmitter.emit (events.js:95:17)
2013-04-30T19:38:32.242663+00:00 heroku[web.1]: Process exited with status 8
2013-04-30T19:38:32.257231+00:00 heroku[web.1]: State changed from starting to crashed

最佳答案

我没有将 redis 实例与客户端一起传递到 RedisStore。

参见:Redis auth error with Node.js and socket.io

关于heroku - socket.io RedisStore 是否适用于 heroku?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16308119/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com