我跟着401-ActionController-Live Railscast和這個Blog Post約Server-Sent-Events
在我的Rails應用中設置了類似的東西。當我僅使用puma
打開到服務器的連接時,它會很好地工作,但在puma + nginx
時,連接在發送第一個數據塊後關閉。在第一批數據(Rails 4 + Puma + Nginx)後,SSE/EventSource關閉
我也試過以下這些問題提供的解決方案,但他們並沒有爲我工作:
- ActionController::Live Streaming dies after first chunk sent
- EventSource/Server-Sent Events through Nginx
這就是我得到:
這是How I set up my Server,這是我目前nginx
配置:
upstream puma {
server unix:///home/deploy/apps/outy/shared/tmp/sockets/outy-puma.sock;
keepalive 16;
}
server {
listen 80 default_server deferred;
root /home/deploy/apps/outy/current/public;
access_log /home/deploy/apps/outy/current/log/nginx.access.log;
error_log /home/deploy/apps/outy/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
proxy_cache off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
你解決你的問題呢? – arturtr 2015-02-25 18:16:44
@arturtr不,我仍然無法解決這個問題 – Sheharyar 2015-02-25 18:45:51