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

Websockets #44

Closed
jgaskins opened this issue Sep 6, 2015 · 4 comments
Closed

Websockets #44

jgaskins opened this issue Sep 6, 2015 · 4 comments

Comments

@jgaskins
Copy link

jgaskins commented Sep 6, 2015

I'm experimenting with a websockets app using Roda on Puma, using the example Roda Websockets chat app:

TypeError: no implicit conversion of Rack::Lint::HijackWrapper into Integer
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/eventmachine-1.0.8/lib/eventmachine.rb:762:in `attach_fd'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/eventmachine-1.0.8/lib/eventmachine.rb:762:in `attach_io'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/eventmachine-1.0.8/lib/eventmachine.rb:745:in `attach'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/faye-websocket-0.10.0/lib/faye/rack_stream.rb:26:in `initialize'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/faye-websocket-0.10.0/lib/faye/websocket.rb:70:in `new'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/faye-websocket-0.10.0/lib/faye/websocket.rb:70:in `initialize'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda/plugins/websockets.rb:92:in `new'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda/plugins/websockets.rb:92:in `block in websocket'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:713:in `always'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda/plugins/websockets.rb:90:in `websocket'
    /Users/jamie/Code/clearwater-chat/clearwater-chat.rb:17:in `block (2 levels) in <class:ClearwaterChat>'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:771:in `if_match'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:494:in `on'
    /Users/jamie/Code/clearwater-chat/clearwater-chat.rb:15:in `block in <class:ClearwaterChat>'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:250:in `instance_exec'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:250:in `block in call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:248:in `catch'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:248:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:222:in `block in build_rack_app'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:114:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/roda-2.5.1/lib/roda.rb:114:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/tempfile_reaper.rb:15:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/lint.rb:49:in `_call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/lint.rb:37:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/showexceptions.rb:24:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/commonlogger.rb:33:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/chunked.rb:54:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/puma-2.13.4/lib/puma/server.rb:541:in `handle_request'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/puma-2.13.4/lib/puma/server.rb:388:in `process_client'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/puma-2.13.4/lib/puma/server.rb:270:in `block in run'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/puma-2.13.4/lib/puma/thread_pool.rb:106:in `call'
    /Users/jamie/.rvm/gems/ruby-2.2.3@clearwater-roda/gems/puma-2.13.4/lib/puma/thread_pool.rb:106:in `block in spawn_thread'
::1 - - [06/Sep/2015:13:24:18 -0400] "GET /chat HTTP/1.1" 500 3570 0.0019

Here's what I'm running on:

  • Ruby 2.2.3
  • Roda 2.5.1
  • Puma 2.13.4
  • Faye::Websocket 0.10.0
@jeremyevans
Copy link
Owner

From the error message, it looks like this is related to Rack::Lint. Can you try running without Rack::Lint and see if it works? Assuming it works without Rack::Lint, this probably a bug in Rack::Lint.

The Roda specs use thin and not puma, but I have tested the websocket support with puma and it does work (slightly older version, 2.12.1, but I doubt that matters).

@jgaskins
Copy link
Author

jgaskins commented Sep 6, 2015

How do I do that? I didn't add it in, the only gems I installed myself were roda, clearwater, faye-websocket, and slim (and maybe one other, but nothing rack-related). So I assumed it was something in the Roda/Rack/Faye triad.

I actually went with Puma as a web server because it didn't work with thin, either, but I figured I was screwing something up. When it didn't work with puma, I figured it might be time to file an issue.

@jeremyevans
Copy link
Owner

I've confirmed this is an issue with Rack::Lint. If I use the Rack::Lint middleware explicitly, I get that error. This is either a bug in Rack::Lint::HijackWrapper or a bug in faye-websocket for not handling Rack::Lint::HijackWrapper. Personally, I think it is a bug in the Rack::Lint. I would file a issue in rack, and if they say it's not a bug in rack, then file a issue in faye-websocket.

I don't think it is a bug in Roda, I think you would run into this in other frameworks that use faye-websocket and Rack::Lint together, unless the framework had a specific workaround for this bug. I try to avoid having framework workarounds for bugs in other libraries, as that makes it less likely for the underlying bug to get fixed.

I think the following is needed to get Rack::Lint::HijackWrapper to work with faye-websocket:

class Rack::Lint::HijackWrapper
  def to_int
    @io.to_i
  end
end

@jgaskins
Copy link
Author

jgaskins commented Sep 7, 2015

Awesome, I really appreciate you taking the time to check it out. I wasn't using Rack::Lint explicitly, but maybe something was injecting it. My own experience in dealing directly with Rack is pretty limited and the hours I spent trying to figure this out were entirely fruitless, mostly because I didn't know what to look for. I'll go ahead and put in an issue on Rack.

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

2 participants