[Solved] Rails – ActionCable: “action_cable.url” for Kubernetes

NevD Asks: Rails – ActionCable: “action_cable.url” for Kubernetes
What config.action_cable.url should be configured for websockets / Rails / Kubernetes ?

When running “docker-compose” with a Rails process (not API only, but with SSR) and a standalone Cable process (the Rails container is run with bundle exec puma -p 28080 ./cable/config.ru as per the guides), the websockets work fine by passing server-side, in say “/config/application.rb”, the following (with theaction_cable_meta_tag set in the layouts):

Code:
config.action_cable.url = 'ws://localhost:28080'

I am targetting Kubernetes: I run a Rails deployment along with a Cable deployment but I can’t make it work. The Cable service is of type “ClusterIP”. I tried several variations; from setting createConsumer('ws://localhost:28080') in the client-side in “/javascript/channels/consumer.js”, to the server-side “/config/application.rb”, such as ws://0.0.0.0:28080 or ws://cable-svc:28080 or ws://cable-svc:28080/cable where “cable-svc” is the name of the cable service.

Any advice?

Note that I use LB -> Nginx -> Rails + Cable on Minikube, and passed:

Code:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.