2

我在 Rails 3 上使用 Faye 进行多人游戏项目。错误

block in close': undefined methodclose_connection_after_writing' 为 nil:NilClass (NoMethodError)

from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket/api.rb:89:in `call'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket/api.rb:89:in `close'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket.rb:198:in `fail'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/connection.rb:155:in `unbind'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:1417:in `event_callback'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/bin/rackup:19:in `load'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/bin/rackup:19:in `<main>'

在我的 faye 服务器使用命令启动后

rackup faye.ru -s Thin -E 生产

我该怎么办这样的错误?是什么原因造成的?我该如何处理?

4

4 回答 4

7

我在这个页面上找到(它是俄语)http://habrahabr.ru/sandbox/45416/

将此添加到您的 faye.ru 文件中

Faye::WebSocket.load_adapter('thin')

这使我的解决方案

我希望它有助于感谢您的建议

于 2012-06-26T08:48:03.253 回答
1

升级faye后我也遇到了这个问题。

要以@tingel2k 的答案为基础,您需要插入以下内容:

Faye::WebSocket.load_adapter('thin')

在应用程序启动之前进入faye.ru,例如:

run Faye::RackAdapter.new(...)
于 2012-06-28T20:20:08.637 回答
1

不要rackup用来启动 faye
而是使用thin start -R faye.ru -e production
这是我的 faye.ru 文件

# encoding: utf-8
require 'faye'
require File.expand_path('../config/initializers/faye_token.rb', __FILE__)

Faye::WebSocket.load_adapter('thin')

class ServerAuth
  def incoming(message, callback)
    if message['channel'] !~ %r{^/meta/}
      if message['ext']['auth_token'] != FAYE_TOKEN
        message['error'] = 'Token de autenticacao invalido'
      end
    end
    callback.call(message)
  end
end

bayeux = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25, :extensions => [ServerAuth.new])
run bayeux
于 2012-06-28T20:22:38.730 回答
0

这是 EventMachine 错误。这个方法接收器是一个连接对象,所以我认为这个错误意味着连接以不正确的方式终止或没有创建。

于 2012-06-01T14:57:27.560 回答