Websocket Rails死锁问题

时间:2014-10-20 07:37:30

标签: ruby-on-rails

在Rails 4应用中出现问题我遇到了死锁错误(详情如下)。我正在使用' websocket-rails'宝石。

这似乎发生在每个第二个请求上,来自dispatcher = new WebSocketRails('localhost:3000/websocket');(来自我的应用程序的前端)

除了github上的faye repo中的旧问题之外,我几乎没有提到这个问题:https://github.com/faye/faye/issues/190

错误:

Started GET "/websocket" for 127.0.0.1 at 2014-10-20 00:26:38 -0700
#<ActionDispatch::Request:0x007fae697e4a18>
Unexpected error while processing request: deadlock; recursive locking

/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:16:in `lock'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:16:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.1.6/lib/action_dispatch/middleware/static.rb:64:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/engine.rb:514:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/application.rb:144:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/faye-websocket-0.7.5/lib/faye/adapters/thin.rb:40:in `process'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/faye-websocket-0.7.5/lib/faye/adapters/thin.rb:44:in `receive_data'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/server.rb:69:in `start'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:81:in `block in server'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `tap'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `server'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
/Users/userme/Desktop/rdio-client-v2/server/bin/rails:8:in `require'
/Users/userme/Desktop/rdio-client-v2/server/bin/rails:8:in `<top (required)>'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/userme/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/userme/Desktop/rdio-client-v2/server/bin/spring:16:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

1 个答案:

答案 0 :(得分:9)

添加

config.middleware.delete Rack::Lock

application.rb会有所帮助。