【问题标题】:WebSocket is closed before the connection is established - Rails 5WebSocket 在建立连接之前关闭 - Rails 5
【发布时间】:2017-11-08 04:06:42
【问题描述】:

我正在尝试让动作电缆工作,但我收到了错误

 WebSocket connection to 'ws://cloud9workspace:3000/cable' failed: WebSocket is closed before the connection is established.

我在谷歌上找遍了,找不到任何有用的东西。我确实在我的 config.ru 中添加了第 3 行,因为 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 是问题的东西。我已经坚持了一段时间了。任何帮助将不胜感激!

【问题讨论】:

  • 从终端工作,您应该能够通过运行telnet cloud9workspace 3000 进行连接。如果这不起作用,那么问题不在于您的 Ruby 代码。
  • 我不确定专业工作区的功能,但您确定您可以访问 Cloud9 中的 3000 端口吗?

标签: ruby-on-rails ruby cloud9-ide


【解决方案1】:

如何运行 ActionCable 独立服务器?你在用彪马吗?

添加cable/config.ru

require_relative '../config/environment'
Rails.application.eager_load!
run ActionCable.server

并启动您的服务器(在 28080 端口上):

bundle exec puma -p 28080 cable/config.ru

【讨论】:

    猜你喜欢
    • 2019-12-14
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多