I'm trying to use Rails 4 Live Streaming component. It all works except that it seems like the stream stays open and blocks new request.
How can I ensure that the connection close down properly when closing down or clicking on a new link within the application?
This is my live event controller.
def events
response.headers["Content-Type"] = "text/event-stream"
redis = Redis.new
redis.psubscribe("participants.*") do |on|
on.pmessage do |pattern, event, data|
response.stream.write("event: #{event}\n")
response.stream.write("data: #{data}\n\n")
end
end
rescue IOError
ensure
redis.quit
response.stream.close
end
Database conf
production:
adapter: postgresql
encoding: unicode
database: ************
pool: 1000
username: ************
password: ************
timeout: 5000
I'm using puma as standalone webserver (i don't have heavy static files that need to be served by nginx) on Ubuntu 10.04 with postgresql 9.2.x.