Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionCable on subdomain instead of subdir

I am trying to get ActionCable work on a subdomain.

the problem is that as soon as I am changing the following line

config.action_cable.mount_path = '/'

The app isn't working anymore. But ActionCable works on a subdomain. Is there any solution to run ActionCable on a subdomain without a subdir like /cable?

like image 318
DjangoSi Avatar asked Aug 21 '17 13:08

DjangoSi


1 Answers

It looks like you'll need to run it as a standalone server if you're not using an in-app server with a sub-uri: https://github.com/rails/rails/tree/master/actioncable#consumer-configuration

You can specify the cable url like so:

config.action_cable.url = 'ws://cable.example.com:28080'

The cable server(s) is separated from your normal application server. It's still a Rack application, but it is its own Rack application. The recommended basic setup is as follows:

# cable/config.ru
require_relative '../config/environment'
Rails.application.eager_load!

run ActionCable.server

Then you start the server using a binstub in bin/cable ala:

#!/bin/bash
bundle exec puma -p 28080 cable/config.ru

https://github.com/rails/rails/tree/master/actioncable#standalone

like image 188
jemminger Avatar answered Oct 16 '22 09:10

jemminger