Skip to content

Conversation

rfestag
Copy link

@rfestag rfestag commented May 22, 2017

I'm not sure if my hot-patching of OpenSSL::SSL::SSLServer is the correct way to do this, but it made it work in my example application. Open to other ideas of how to do it "correctly".

@rfestag
Copy link
Author

rfestag commented May 22, 2017

FYI - If you want to test it, this is my sample application:
https://github.com/rfestag/helix

I'm pretty sure it doesn't work correctly (check out lib/helix/server.rb). When I try to do a large number of concurrent requests, I end up only being able to serve 2 req/s. I suspect I'm not using tasks correctly.

@coveralls
Copy link

coveralls commented May 22, 2017

Coverage Status

Coverage remained the same at 97.245% when pulling 3fb70b1 on rfestag:master into 60fe791 on socketry:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.245% when pulling 3fb70b1 on rfestag:master into 60fe791 on socketry:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.245% when pulling 3fb70b1 on rfestag:master into 60fe791 on socketry:master.

@ioquatix
Copy link
Member

I will review this once we have something to rebase it on to.

@tarcieri
Copy link

tarcieri commented May 22, 2017 via email

@ioquatix
Copy link
Member

@tarcieri Yeah, I agree, monkey patching the core is a bad idea. However, it's great that people are interested in the project and I'm sure we can use what has been done here as a base implementation for how to get things working.

@rfestag
Copy link
Author

rfestag commented May 23, 2017

I agree, but I didn't see a way around it in terms of how async was implemented (i.e., it expected methods to exist on the SSLServer that did not). That is the main reason I asked for alternatives, so thanks for pointing out Socketry. The point is mostly moot at this point, considering the direction the async gem itself is going. I think it certainly makes more sense to base async's sockets on socketry (or use it directly).

I actually looked at socketry briefly, but noticed in the README that it implemented synchronous semantics, and that it also lacked an accept_nonblock for SSL. I assume there is a reason for it (considering the core Ruby library does the same thing). I'll play with it and see if I can make it work with my project. I assume I can use socketry with nio4r in order to get back to async? That's at least what I'm planning to try out in the interim, unless I'm missing something.

@ioquatix
Copy link
Member

So the simple solution is that when you initialize OpenSSL server, you pass in a TCP server which implements non-blocking accept - I think that solves most of the issues, but I'll review it once I have time.

@ioquatix
Copy link
Member

Also you are right the synchronous IO model of socketry makes this a bit harder to use. However, the core async gem no longer cares about IO at all - it's a pure reactor. There is going to be a separate gem with all the Ruby-native IO wrappers, thats where this PR should land. In addition, we can explore supporting socketry on top of async, which should not only be feasible now, but a great idea - I'd like to keep options open - people can make their own choice about high level library. async is purely about scheduling and I'm trying to make it as free as possible from any kind of opinion on how IO should work.

That's not the case with the async io wrappers which are coming up soon - they are opinionated and prefer blocks for resource management purposes.

@ioquatix
Copy link
Member

Can we please move this to https://github.com/socketry/async-io - thanks so much for your effort.

@ioquatix ioquatix closed this May 24, 2017
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

Successfully merging this pull request may close these issues.

4 participants