【发布时间】:2014-12-07 07:44:58
【问题描述】:
当我刷新打开 websocket 的页面时,刷新页面上出现“内部服务器错误” 我找不到这个问题的任何解决方案。我正在使用 rails 4.1.8、websocket-rails gem、thin server。
这是我的 Rails 日志...
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/>
【问题讨论】:
标签: javascript ruby-on-rails-4 websocket