I am using Amazon Elastic Beanstalk (Nginx 1.4.2 + Passenger 4.0.20 + Ruby 1.9.3) to deploy a sinatra app that uses Server Sent Events. Everything works perfectly on local machine using thin. On AWS Elastic Beanstalk though, the connection gets dropped after milliseconds.
server code look like this:
get '/stream', provides: 'text/event-stream' do
response.headers['X-Accel-Buffering'] = 'no'
stream :keep_open do |out|
settings.connections << out
out.callback { settings.connections.delete(out) }
end
end
On the server log I see a connection timeout:
2013/11/20 19:45:46 [info] 9716#0: *35 client closed connection while waiting for request, client: xxx.xxx.xxx.xxx, server: 0.0.0.0:80
Tried the nginx configuration suggested here (EventSource / Server-Sent Events through Nginx) under the server block and although the header response changes, it is not yet working.
(I had to set X-Accell-Buffering on Nginx file as well, because it would not take the setting set in server code with sinatra)
Response header looks something like this:
HTTP/1.1 200 OK
Content-Type: text/event-stream;charset=utf-8
Date: Wed, 20 Nov 2013 20:03:06 GMT
Server: nginx/1.4.2 + Phusion Passenger 4.0.20
Status: 200 OK
X-Accel-Buffering: no
X-Content-Type-Options: nosniff
X-Powered-By: Phusion Passenger 4.0.20
transfer-encoding: chunked
Connection: keep-alive
Any ideas?
Thanks in advance.