在我的应用中,我有一个ActionCable,该电缆在本地运行良好,但不能强制其在生产服务器上运行。
我的堆栈是:
资产/javascripts/channels/index.coffee
App.cable = ActionCable.createConsumer("/cable")
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer("/cable")
}).call(this);
mount ActionCable.server => "/cable"
config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]
server{
server_name subdomain.my-app.app;
passenger_enabled on;
rails_env production;
root /home/deploy/my-app/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/iris.gemisoft.app/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/iris.gemisoft.app/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# REDIS / ACTIONCABLE
location /cable {
passenger_app_group_name subdomain_my-app_app_websocket;
passenger_force_max_concurrent_requests_per_process 0;
}
}
server {
# if ($host = subdomain.my-app.app) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
listen 80;
listen [::]:80 ipv6only=on;
server_name subdomain.my-app.app;
#return 404; # managed by Certbot
}
Expected behaviour: When Admin click a button, users gets a message.
Current behaviour (on prod): When admin clicks a button, nothing happens, in redis console i can see:
1559571365.936128 [1 127.0.0.1:53530] "publish" "test" "{\"message\":\"message\"}"
更新:cable.yml:
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: redis
url: redis://localhost:6379/1
production:
adapter: redis
url: redis://localhost:6379/1
答案 0 :(得分:0)
我找到了解决方案。在我的设置中,我同时拥有jquery_ujs和rails-ujs。通过删除jquery_ujs解决了问题。