我正在尝试让 Action 电缆工作,但出现错误
WebSocket connection to 'ws://cloud9workspace:3000/cable' failed: WebSocket is closed before the connection is established.
我已经搜索了整个谷歌,但找不到任何有用的东西。我确实将第 3 行添加到我的 config.ru 中,因为 Cloud9 社区的某个人说他们尝试过并且有效。虽然它对我不起作用。
require ::File.expand_path('../../config/environment', __FILE__)
Rails.application.eager_load!
ActionCable.server.config.disable_request_forgery_protection = true
run ActionCable.server
我在 cloud9 上使用专业工作区,但我没有看到任何迹象表明 cloud9 是问题所在。我已经坚持了一段时间了。任何帮助将不胜感激!
最佳答案
运行 ActionCable 独立服务器怎么样?你在用 puma 吗?
添加cable/config.ru
require_relative '../config/environment'
Rails.application.eager_load!
run ActionCable.server
然后启动你的服务器(在 28080 端口):
bundle exec puma -p 28080 cable/config.ru
关于ruby-on-rails - 在建立连接之前关闭 WebSocket - Rails 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47171411/