I have a Rails 4.1 application with a simple controller that passes the response:
class ServerSentEventsController < ApplicationController
include ActionController::Live
def index
response.headers['Content-Type'] = 'text/event-stream'
sse = ServerSentEvent.new(response.stream)
begin
loop do
sse.write(time: Time.now)
sleep 1
end
rescue IOError
ensure
sse.close
end
end
end
When I add puma to my gemfile and make a request for this route with curl, I get a streaming response as expected:
curl -i 'http://localhost:3000/sse'
data: {"time":"2014-08-29 05:16:00 +0100"}
data: {"time":"2014-08-29 05:16:01 +0100"}
data: {"time":"2014-08-29 05:16:02 +0100"}
When I switch to thin in my gemfile and make a request, the whole thing is blocked. I read in several places that thin can handle concurrent requests, but I can't get it to work.
I start puma just by running bundle exec rails server. For thin, I tried bundle exec rails serverseveral configurations of the type bundle exec thin start -a 127.0.0.1 -threaded. Nothing seems to interfere with subtle locking.
How can I get subtle to accept concurrent requests?