ngauthier/tubesock

Puma crashed with tubesock.

Closed this issue · 0 comments

/home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:41:in `write': Bad file descriptor (Errno::EBADF)
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:41:in `send_data'
    from /home/app/releases/20140903142948/app/controllers/stream_controller.rb:87:in `block (2 levels) in index'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:64:in `call'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:64:in `block (3 levels) in listen'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:64:in `each'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:64:in `block (2 levels) in listen'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:105:in `each_frame'
    from /home/app/shared/bundle/ruby/2.1.0/gems/tubesock-0.2.3/lib/tubesock.rb:63:in `block in listen'

Controller method checks active sockets and sends them data:

  def user_sockets
    @@sockets ||= []
    @@sockets.delete_if { |socket, _user| socket.instance_variable_get('@socket').closed? }
    @@sockets
  end

def update
    user_sockets.each do |s, _|
        sock.send_data(json_data)
    end
end