ruby-on-rails - Rails 服务器在 rake 任务中不以 web 套接字和 redis 选项启动。

标签 ruby-on-rails websocket redis rake

我必须在 rake 任务中使用 websockets,为此我将 event.rb 更改为

 config.synchronize = true  
  # Uncomment and edit to point to a different redis instance.
  # Will not be used unless standalone or synchronization mode
  # is enabled.
 config.redis_options = {:host => 'localhost', :port => '3000'}

当我启动我的 rails 服务器时,我得到了这个错误:

! Invalid request
Exiting
/usr/local/rvm/gems/ruby-1.9.3-p194@socialmail/gems/redis-3.0.4/lib/redis/connection/synchrony.rb:115:in `read':  Got 'Protocol error, got "H" as reply type byte' as initial reply byte. If you're in a forking environment, such as Unicorn, you need to connect to Redis after forking.  (Redis::ProtocolError)

我做错了什么?

谢谢

最佳答案

嘿,谢谢你提出这个问题,我个人无法获得我的 rake 任务来发布到我在 Rails 服务器上打开的 websocket channel 。您的同步命令有所帮助(以及在本地启动 Redis 服务器)。

您的问题似乎是指向 3000。那是您的 Rails 服务器还是 Redis 实例?如果您在本地运行它,我会省略该行。

关于ruby-on-rails - Rails 服务器在 rake 任务中不以 web 套接字和 redis 选项启动。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17801965/

相关文章:

c++ - 将 Websocket 与 Poco 库连接

redis - DECR后如何重置Redis中的键增量?

ruby-on-rails - Rspec Factory Girl 模型单数复数(未初始化常量 [ModelName])

ruby-on-rails - Rails 回形针 `is not recognized by the ' 识别'命令`

ruby-on-rails - 这种计算是放​​在Model还是Controller?

php - 用于树莓派的 Ratchet Websocket

c++ - Windows vc++ websocket E_INVALID_PROTOCOL_FORMAT

database-design - Redis中最快的伪索引是什么?

c# - 使用默认队列时类型不包含方法

ruby-on-rails - 是否有替代的 Ctrl+C 来停止 Rails 服务器?