Private_pub 和 Rainbows 配置中的配置问题

Posted

技术标签:

【中文标题】Private_pub 和 Rainbows 配置中的配置问题【英文标题】:Config issue in Private_pub and rainbows configuration 【发布时间】:2013-06-03 17:18:37 【问题描述】:

我已经为 private_pub 配置了这样的彩虹

rainbows.conf:

Rainbows! do 


end 

private_pub.ru:

require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
require "faye/redis"


Faye::WebSocket.load_adapter('rainbows')
yml = YAML::load_file("config/private_pub_redis.yml")[ENV["RAILS_ENV"] || "development"]
PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
run PrivatePub.faye_app(:timeout => 1, :engine => 
  :type  => Faye::Redis,
    :host  => yml["server"],
    :port  => yml["port"]
)

我使用这个来运行服务器:

rainbows private_pub.ru -c config/rainbows.conf -E production -p 9292

现在每次页面加载订阅时我都会收到此错误并且订阅失败:

在浏览器上加载页面时的服务器错误日志:

E, [2013-06-03T22:29:10.673828 #17953] ERROR -- : app error: undefined method call' for nil:NilClass (NoMethodError)
E, [2013-06-03T22:29:10.674195 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-websocket-0.4.7/lib/faye/websocket.rb:143:ininitialize'
E, [2013-06-03T22:29:10.674343 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:131:in new'
E, [2013-06-03T22:29:10.674465 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:131:inhandle_websocket'
E, [2013-06-03T22:29:10.674563 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/faye-0.8.9/lib/faye/adapters/rack_adapter.rb:88:in call'
E, [2013-06-03T22:29:10.674642 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:66:inblock in call'
E, [2013-06-03T22:29:10.674717 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:59:in catch'
E, [2013-06-03T22:29:10.674790 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/max_body.rb:59:incall'
E, [2013-06-03T22:29:10.674863 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/process_client.rb:44:in process_loop'
E, [2013-06-03T22:29:10.674937 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/base.rb:32:inprocess_client'
E, [2013-06-03T22:29:10.675015 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:632:in worker_loop'
E, [2013-06-03T22:29:10.675099 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/http_server.rb:45:inworker_loop'
E, [2013-06-03T22:29:10.675172 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in spawn_missing_workers'
E, [2013-06-03T22:29:10.675243 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/lib/rainbows/http_server.rb:61:inspawn_missing_workers'
E, [2013-06-03T22:29:10.675315 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:142:in start'
E, [2013-06-03T22:29:10.675387 #17953] ERROR -- : /var/lib/gems/1.9.1/gems/rainbows-4.5.0/bin/rainbows:127:in'
E, [2013-06-03T22:29:10.675458 #17953] ERROR -- : /usr/local/bin/rainbows:23:in load'
E, [2013-06-03T22:29:10.675529 #17953] ERROR -- : /usr/local/bin/rainbows:23:in'

浏览器控制台错误登录:

GET http://localhost:9292/faye?message=%5B%7B%22channel%22%3A%22%2Fmeta%2Fhands…3A%5B%22callback-polling%22%5D%2C%22id%22%3A%221%22%7D%5D&jsonp=__jsonp1__ 400 (Bad Request) faye.js:1
WebSocket connection to 'ws://localhost:9292/faye' failed: Unexpected response code: 500 http://localhost:8080/
WebSocket connection to 'ws://localhost:9292/faye' failed: WebSocket is closed before the connection is established.

【问题讨论】:

【参考方案1】:

对于遇到相同问题的任何人,答案都在这里:https://groups.google.com/forum/#!topic/faye-users/oQ5JCoV7qh8

这里的问题是我使用的是旧版本的 faye-websocket。

另一个问题是我使用的是 Rainbows 4.5 而 faye[0.8] 支持旧的 Rainbows

【讨论】:

以上是关于Private_pub 和 Rainbows 配置中的配置问题的主要内容,如果未能解决你的问题,请参考以下文章

html Unicorn Shitting Rainbows - Konami代码开始有趣

js.erb 文件正在执行两次。 Ruby on Rails - private_pub

第三次作业-功能测试

[提取后读取文件的内容

第四次作业四则运算

彩虹工人在超时后被杀死,即使它回复了