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

8.1 breaks Celluloid::IO compatibility? #203

Closed
zuk opened this issue Apr 6, 2015 · 13 comments
Closed

8.1 breaks Celluloid::IO compatibility? #203

zuk opened this issue Apr 6, 2015 · 13 comments
Assignees
Milestone

Comments

@zuk
Copy link

zuk commented Apr 6, 2015

The following code works in 7.x but seems to be broken in 8.1:

require 'celluloid/io'
require 'http'

class Foo
  include Celluloid::IO

  def req
    HTTP
    .get("https://www.google.com", ssl_socket_class: Celluloid::IO::SSLSocket)
  end
end

foo = Foo.new
future = foo.future.req

puts future.value

Running this under 8.1 gets me:

.../ruby-2.1.5/gems/http-0.8.1/lib/http/timeout/null.rb:29:in `start_tls': undefined method `sync_close=' for #<Celluloid::IO::SSLSocket:0x007fcdbce990d0> (NoMethodError)
    from .../ruby-2.1.5/gems/http-0.8.1/lib/http/connection.rb:141:in `start_tls'

But under 7.2 it works as expected.

Am I doing something wrong or does the new timeout code break Celluloid::IO compatibility?

@zuk
Copy link
Author

zuk commented Apr 6, 2015

By the way, I'm not sure how to set httprb to use a different timeout class. If I do the following, I still get the backtrace showing timeout/null.rb:

HTTP
.get("https://www.google.ca/",
  ssl_socket_class: Celluloid::IO::SSLSocket,
  timeout_class: HTTP::Timeout::Global,
  timeout_options: {
    connect_timeout: 5,
    read_timeout: 5,
    write_timeout: 5
  }
)

@ixti
Copy link
Member

ixti commented Apr 6, 2015

@zanker seems like we have lost if respond_to? in cycles of refactoring: https://github.com/httprb/http.rb/blob/master/lib/http/timeout/null.rb#L29

@tarcieri
Copy link
Member

tarcieri commented Apr 6, 2015

Yeah, I guess this was in the back of my mind but we never looped back on it.

I think it would be nice if there were a high-level API to wire everything (socket classes, timeouts) up for Celluloid::IO. Something like:

HTTP.backend(:celluloid)

@zuk stick with 0.7 until we sort this out

@ixti
Copy link
Member

ixti commented Apr 6, 2015

@zuk Thanks for your report. Will release a patch in a moment.

@ixti
Copy link
Member

ixti commented Apr 6, 2015

@tarcieri absolutely in love with HTTP.backend(:celluloid) proposal!

@zuk
Copy link
Author

zuk commented Apr 6, 2015

I know this is a bit off topic, but any info on how to switch to a different timeout class (e.g. Global, or PerRequest)? Really having a hard time gleaning this from the recent commits.

@ixti
Copy link
Member

ixti commented Apr 6, 2015

@zuk 0.8.2 with fix released. Your variant should work fine (it was failing due to the regression you noticed). So this one should work:

HTTP
.get("https://www.google.ca/",
  ssl_socket_class: Celluloid::IO::SSLSocket,
  timeout_class: HTTP::Timeout::Global,
  timeout_options: {
    connect_timeout: 5,
    read_timeout: 5,
    write_timeout: 5
  }
)

@zuk
Copy link
Author

zuk commented Apr 6, 2015

Hate to say it but now getting the following error with 8.2:

.../gems/http-0.8.2/lib/http/timeout/global.rb:26:in `connect_ssl': undefined method `connect_nonblock' for #<Celluloid::IO::SSLSocket:0x007fad44a7e790> (NoMethodError)
    from .../gems/ruby-2.1.5/gems/http-0.8.2/lib/http/timeout/null.rb:31:in `start_tls'

@tarcieri
Copy link
Member

tarcieri commented Apr 6, 2015

@zuk http.rb 0.8+ is going to need a separate timeout backend for Celluloid::IO before it will work correctly. Stick with 0.7 for now.

@ixti
Copy link
Member

ixti commented Apr 6, 2015

Hm... I was testing example locally and it was just fine :((

@zanker
Copy link
Contributor

zanker commented Apr 6, 2015

Ah yea, sync_close was missed. Although it looks like Celluloid is leaking SSL sockets since it should set that by default. So I also just enabled that option in Celluloid celluloid/celluloid-io#135

@ixti ixti added this to the v0.9 milestone Apr 12, 2015
@zanker
Copy link
Contributor

zanker commented May 8, 2015

Sorry got a bit busy. Http.rb will work with Celluloid, as long as you don't use timeouts. The null timeout backend should work fine with Celluloid, since the sync_close= fix was made in Http.rb. It'll be fixed in Celluloid::IO whenever they tag a new version.

#216

@zanker zanker closed this as completed May 8, 2015
@ixti
Copy link
Member

ixti commented May 8, 2015

👍

@ixti ixti modified the milestones: v0.10, v0.9 Jul 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants