当我刷新websocket打开的页面时,我在刷新的页面上出现“内部服务器错误” 我找不到任何解决这个问题的方法..我正在使用rails 4.1.8,websocket-rails gem,瘦服务器。
这是我的rails log ...
Unexpected error while processing request: deadlock; recursive locking
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/lock.rb:16:in `lock'
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/lock.rb:16:in `call'
/usr/local/share/gems/gems/actionpack-4.1.8/lib/action_dispatch/middleware/static.rb:84:in `call'
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'
/home/john/.gem/ruby/gems/faye-websocket-0.8.0/lib/faye/adapters/thin.rb:40:in `process'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'
/home/john/.gem/ruby/gems/faye-websocket-0.8.0/lib/faye/adapters/thin.rb:44:in `receive_data'
/home/john/.gem/ruby/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/john/.gem/ruby/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'
/home/john/.gem/ruby/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
/usr/local/share/gems/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands/server.rb:69:in `start'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:in `block in server'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
/usr/local/share/gems/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
这是我的客户端代码
<script>
var dispatcher_stock_table = new WebSocketRails($('.table').data('uri'), true);
dispatcher_stock_table.on_open = function() {
console.log('Connection has been established:');}
dispatcher_stock_table.on_close = function(closed) {
console.log('Connection has been closed:'+closed);}
var getvalues = function(value){
var valuenum = value.split('_')[1];
var data = {identity: valuenum,value: document.getElementById(value).value};
console.log(data);
var success = function(response) {
console.log("Wow it worked: "+response.message);
dispatcher_stock_table.unbind('stock_ajax_handler');
}
var failure = function(response) {
console.log("That just totally failed: "+response.message);
}
dispatcher_stock_table.trigger('stock_ajax_handler', data, success, failure);
function gettable(gettable_and_flashnotice) {
console.log(gettable_and_flashnotice.sent_data.notice);
dispatcher_stock_table.on_close("closed");
}
dispatcher_stock_table.bind('stock_ajax_handler', gettable);
// var channel = dispatcher.subscribe('<%=current_user.id%>');
// channel.trigger('notification_update',sent,success,failure);
// channel.bind('notification_update', function(data) {
// console.log('channel event received: ' + data);});
// channel.unbind('notification_update');
};
<script/>
答案 0 :(得分:2)
我正在使用rails 4.1.8,但看起来您必须将以下行添加到您的development.rb文件中
config.middleware.delete Rack :: Lock
将它添加到development.rb文件......它解决了我的问题,引用(http://richardyuwono.org/post/85523208658/heroku-websocket-rails-rails-4)和websocket-rails irc频道(@moa)的人帮助我