Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4.2.0.beta2 Support #32

Open
tyrauber opened this issue Nov 9, 2014 · 8 comments
Open

Rails 4.2.0.beta2 Support #32

tyrauber opened this issue Nov 9, 2014 · 8 comments

Comments

@tyrauber
Copy link

tyrauber commented Nov 9, 2014

Tubesock crashes in Rails4.2.0.beta with the following error:

 Started GET "/chat" for ::1 at 2014-11-09 14:20:01 -0800
 Processing by ChatController#chat as HTML
   Rendered text template (0.1ms)
 Completed -1  in 12ms (Views: 3.4ms | ActiveRecord: 0.0ms)
 Rack::Lint::LintError: Status must be >=100 seen as integer
 Exiting
 /gems/tubesock-0.2.4/lib/tubesock.rb:96:in `select': no implicit conversion of Rack::Lint::HijackWrapper into IO (TypeError)

This can be demonstrated in the sock-chat demo app by updating the Gemfile to Rails 4.2.0.beta2.

@seban
Copy link

seban commented Apr 15, 2015

Any update on that?

@ngauthier
Copy link
Owner

My memory is a little rust but I think the Rack Hijack spec says to return
a 0, which is why tubesock does that. Perhaps that has changed?
On Apr 15, 2015 6:21 AM, "Sebastian Nowak" notifications@github.com wrote:

Any update on that?


Reply to this email directly or view it on GitHub
#32 (comment).

@vmoravec
Copy link

@ngauthier Looks like it has, see this: rack/rack@36a2145

@ngauthier
Copy link
Owner

So perhaps it's ok to just return a 200? Can anyone try it out?

@vmoravec
Copy link

It returns tubesock-0.2.5/lib/tubesock.rb:100:in select': no implicit conversion of Rack::Lint::HijackWrapper into IO error

@seban
Copy link

seban commented Apr 17, 2015

It is because newer version of rack has Rack::HiJackWrapper with slighty different interface which tubesock didn't support now. I will submit a patch later today or in the weekend. Currently I monkey-patched it in my project and it works smoothly.

@ngauthier
Copy link
Owner

Thanks

On Fri, Apr 17, 2015 at 2:12 PM, Sebastian Nowak notifications@github.com
wrote:

It is because newer version of rack has Rack::HiJackWrapper with slighty
different interface which tubesock didn't support now. I will submit a
patch later today or in the weekend. Currently I monkey-patched it in my
project and it works smoothly.


Reply to this email directly or view it on GitHub
#32 (comment).

@seban
Copy link

seban commented Apr 19, 2015

Spend some time on it. Locally I have problems to update tests to pass with my code so instead of PR I show you my code. My monkey-patch looks like:

def each_frame
  framebuffer = WebSocket::Frame::Incoming::Server.new(version: @version)
  io = @socket.instance_variable_get(:@io)
  while IO.select([io])
  if @socket.respond_to?(:recvfrom)
    data = io.recvfrom(2000)
  else
     data = io.readpartial(2000) #, @socket.peeraddr
  end
  break if data.empty?
  framebuffer << data
  while frame = framebuffer.next
    case frame.type
      when :close
        return
      when :text, :binary
        yield frame.data
      end
    end
  end
rescue Errno::EHOSTUNREACH, Errno::ETIMEDOUT, Errno::ECONNRESET, IOError, Errno::EBADF
  nil # client disconnected or timed out
end

I am sure it could be better implemented, but it shows idea what have changed. Rack::HiJackWrapper has some forward method defined https://github.com/rack/rack/blob/master/lib/rack/lint.rb#L498 maybe some of them can be used here instead of directly messing up with wrapper io instance variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants