gpt4 book ai didi

ruby-on-rails - 未触发 Actioncable 超时断开连接

转载 作者:行者123 更新时间:2023-12-04 03:19:02 25 4
gpt4 key购买 nike

在 Actioncable 上,当我禁用我的 wifi 以模拟互联网丢失时,Channel 中的 unsubscribed 方法或 Connection 中的 disconnect 方法没有触发。如何激活超时断开?

这是我使用 rails/capistrano/puma/nginx 的 actioncable 配置:

Rails 5.0.0.1 端:

# config/cable.yml
staging:
adapter: redis
url: redis://localhost:6379/1

# cable/config.ru
require ::File.expand_path('../../config/environment', __FILE__)
Rails.application.eager_load!

run ActionCable.server

和 capistrano/puma

set :puma_rackup, -> { File.join(current_path, 'cable/config.ru') }

Nginx 方面:

upstream app {
server unix:/home/ubuntu/rails-app/shared/tmp/sockets/puma.sock fail_timeout=0;
}

server {
listen 443 ssl;
server_name ws.domain.co;

ssl on;
ssl_certificate /etc/letsencrypt/live/domain.co/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.co/privkey.pem;

ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Upgrade websocket;
proxy_set_header Connection Upgrade;
}

}

最佳答案

我也遇到过这个问题,似乎确实会触发断开连接。只是不像文档中描述的那样在几秒钟内完成,而是在几分钟内完成。

你可以 'watch -n 1 'netstat -na | grep YourPort' 以查看连接实际上仍然存在,因此不应触发断开连接回调。

我已经在 github 上打开了一个关于这个问题的问题。 https://github.com/rails/rails/issues/27082

关于ruby-on-rails - 未触发 Actioncable 超时断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39509213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com