【问题标题】:ActionCable on subdomain instead of subdir子域而不是子目录上的 ActionCable
【发布时间】:2018-01-29 14:47:58
【问题描述】:

我正在尝试让 ActionCable 在子域上工作。

问题是,只要我更改以下行

config.action_cable.mount_path = '/'

该应用程序不再工作。但是 ActionCable 在子域上工作。是否有任何解决方案可以在没有像 /cable 这样的子目录的子域上运行 ActionCable?

【问题讨论】:

  • 我也想要这个问题的答案

标签: ruby-on-rails actioncable


【解决方案1】:

如果您不使用带有子 uri 的应用内服务器,您似乎需要将其作为独立服务器运行:https://github.com/rails/rails/tree/master/actioncable#consumer-configuration

您可以像这样指定电缆网址:

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

有线服务器与您的普通应用服务器分开。它仍然是一个 Rack 应用程序,但它是它自己的 Rack 应用程序。推荐的基本设置如下:

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

run ActionCable.server

然后你使用 bin/cable ala 中的 binstub 启动服务器:

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

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

【讨论】:

  • 这取决于您如何配置有线服务器。我已将该信息添加到答案中
  • “如果您不使用带有子 uri 的应用内服务器,您似乎需要将其作为独立服务器运行”您提到的链接似乎不起作用了。你能详细说明一下吗?
  • @LuisVasconcellos 好像搬到了这里:edgeguides.rubyonrails.org/…
猜你喜欢
  • 2011-09-04
  • 2019-04-29
  • 2013-09-12
  • 2021-04-30
  • 2014-10-30
  • 1970-01-01
  • 2011-06-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多