Broadcasting not works from rails controllers #155
-
#This is works correct from rails Models
Turbo::StreamsChannel.broadcast_replace_to(
"resource:#{resource.id}",
target: "some_target",
html: ApplicationController.render(
HUi::SomeComponent::SomeComponent.new(resource: resource),
layout: false
)
)
#This is works correct too from rails Channels
ResourceChannel.broadcast_to(
self.resource,
type: 'fuckResource',
request_identify: request_identify,
data: data
) The problem is second example NOT works from rails controllers in production. Only in development on my macbook. No errors in anycable-go OR anycable-rpc services. Also when i trying to pass ssl cert files to My files:#/etc/nginx/sites-enabled/blabla.conf
server{
server_name dev.blabla.com;
root /home/serhii/apps/blabla/public;
client_max_body_size 100m;
passenger_enabled on;
passenger_app_env production;
location /cable {
passenger_app_group_name blabla_websocket;
passenger_force_max_concurrent_requests_per_process 0;
proxy_pass http://127.0.0.1:3334;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ ^/assets {
expires max;
gzip_static on;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dev.blabla.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dev.blabla.com/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
}
server{
if ($host = dev.blabla.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name dev.blabla.com;
return 404; # managed by Certbot
} # /etc/systemd/system/anycable-go.service
[Unit]
Description=AnyCable Go WebSocket Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/serhii/go
ExecStart=/home/serhii/go/bin/anycable-go
ExecStop=/bin/kill -TERM $MAINPID
User=serhii
Group=serhii
UMask=0002
LimitNOFILE=16384
Restart=on-failure
#Environment="APP_NAME=blabla"
#Environment="SUBDOMAIN=dev"
#Environment="CABLE_URL=wss://dev.blabla.com:3334/cable"
Environment="ANYCABLE_HOST=localhost"
Environment="ANYCABLE_PORT=3334"
Environment="ANYCABLE_PATH=/cable"
Environment="ANYCABLE_REDIS_URL=redis://localhost:6379/1"
Environment="ANYCABLE_REDIS_CHANNEL=__anycable__"
Environment="ANYCABLE_RPC_HOST=localhost:50051"
Environment="ANYCABLE_METRICS_HTTP=/metrics"
[Install]
WantedBy=multi-user.target # /etc/systemd/system/anycable-rpc.service
[Unit]
Description=AnyCable gRPC Server
After=syslog.target network.target
[Service]
Type=simple
Environment="RAILS_ENV=production"
Environment="RAILS_MASTER_KEY=justlol"
Environment="APP_NAME=blabla"
Environment="RAILS_SECRET_KEY_BASE=looooooonglol"
Environment="SUBDOMAIN=dev"
Environment="CABLE_URL=wss://dev.blabla.com:3334/cable"
WorkingDirectory=/home/serhii/apps/blabla
ExecStart=/bin/bash /home/serhii/.rvm/gems/ruby-3.1.1@r7023/wrappers/bundle exec anycable
ExecStop=/bin/kill -TERM $MAINPID
User=serhii
Group=serhii
UMask=0002
MemoryHigh=2G
MemoryMax=3G
MemoryAccounting=true
Restart=on-failure
Environment="ANYCABLE_HOST=localhost"
Environment="ANYCABLE_PORT=3334"
Environment="ANYCABLE_PATH=/cable"
Environment="ANYCABLE_REDIS_URL=redis://localhost:6379/1"
Environment="ANYCABLE_REDIS_CHANNEL=__anycable__"
Environment="ANYCABLE_RPC_HOST=localhost:50051"
Environment="ANYCABLE_METRICS_HTTP=/metrics"
[Install]
WantedBy=multi-user.target |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, I can't see any obvious errors in your configuration. Please, re-check that you have enabled In general you don't need to set up SSL between Nginx and anycable-go and between anycable-go and anycable-rpc: let Nginx terminate SSL for you. Check your configuration against relevant docs: https://docs.anycable.io/rails/getting_started?id=configuration and https://docs.anycable.io/deployment/ Hope it will help. |
Beta Was this translation helpful? Give feedback.
Hey, I can't see any obvious errors in your configuration.
Please, re-check that you have enabled
any_cable
adapter inconfig/cable.yml
for production environment. Also make sure that you have specifiedANYCABLE_REDIS_URL
andANYCABLE_REDIS_CHANNEL
for all components of your application: including application server (Passenger as far as I can see)In general you don't need to set up SSL between Nginx and anycable-go and between anycable-go and anycable-rpc: let Nginx terminate SSL for you.
Check your configuration against relevant docs: https://docs.anycable.io/rails/getting_started?id=configuration and https://docs.anycable.io/deployment/
Hope it will help.