Inspired by the RailsCast on HTTP Streaming, I've decided to turn it on on my server. However, the listen 3000 :tcp_nopush => false
line that Ryan suggests adding to my unicorn.rb
doesn't play well with Heroku (they don't let you specify a port). Is streaming supported on Heroku, and how do I turn it on?
Asked
Active
Viewed 2,862 times
4

Sudhir Jonathan
- 16,998
- 13
- 66
- 90
1 Answers
9
Heroku tells your application what port to listen on via the environment variable PORT. Check for this environment variable in your unicorn.rb
.
port = ENV["PORT"].to_i
listen port, :tcp_nopush => false

yfeldblum
- 65,165
- 12
- 129
- 169
-
Thanks :D It just hit me that the config was actually plain ruby :-/ – Sudhir Jonathan Aug 30 '11 at 06:32
-
This doesn't seem to be compatible with `Rack::Deflater`, though. My pages keep giving transfer chunked errors when Deflater is used with HTTP Streaming. – Sudhir Jonathan Sep 01 '11 at 18:39
-
`Rack::Chunked` should precede `Rack::Deflater` in the list of middlewares. – yfeldblum Sep 01 '11 at 18:42
-
Does anyone know a solution to the deflater issue? I've posted a separate question here: http://stackoverflow.com/questions/7986150/http-streaming-in-rails-not-working-when-using-rackdeflater – Baversjo Nov 03 '11 at 20:03