首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图修复GET /cable上的机架棉线错误和500

试图修复GET /cable上的机架棉线错误和500
EN

Stack Overflow用户
提问于 2022-02-10 22:43:57
回答 1查看 59关注 0票数 0

我使用角动电缆在我们的rails后端和angularjs前端实现了动作电缆,所有这些都按预期工作,建立了客户端到服务器的websocket连接,广播和接收都在工作,但是当我启动应用程序时,它总是在GET /cable上抛出一个机架线错误和500个错误。

代码语言:javascript
复制
09:33:10 web.1       | Rack::Lint::LintError: Status must be >=100 seen as integer
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:25:in `assert'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:675:in `check_status'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:70:in `_call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/lint.rb:42:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/chunked.rb:98:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/content_length.rb:17:in `call'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:632:in `process_client'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:728:in `worker_loop'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:548:in `spawn_missing_workers'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:144:in `start'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/unicorn-5.7.0/bin/unicorn:128:in `<top (required)>'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/bin/unicorn:23:in `load'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/bin/unicorn:23:in `<top (required)>'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli.rb:476:in `exec'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/cli.rb:24:in `start'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:46:in `block in <top (required)>'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:34:in `<top (required)>'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/bin/bundle:23:in `load'
09:33:10 web.1       |  /home/leonidas/.asdf/installs/ruby/2.7.3/bin/bundle:23:in `<main>'
09:33:10 web.1       | 127.0.0.1 - - [11/Feb/2022:09:33:10 +1100] "GET /cable/ HTTP/1.1" 500 3356 0.4378

我把指纹放在架子上,它返回-1的状态,找不到任何关于-1意味着什么的文档。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-15 02:24:13

对于其他有同样问题的人,原因是Rack做套接字劫持,同时将http协议升级到websockets,并返回a -1,而机架lint并不认为它是有效的http satus,在开发过程中,您可以将RACK_ENV=deployment RAILS_ENV=development设置为测试,并且可以使用简单的初始化器、更详细的这里、上面链接中的初始化器来对操作电缆的头/状态检查进行存根。

代码语言:javascript
复制
class ::Rack::Lint
  alias check_status_orig check_status
  alias check_headers_orig check_headers
  alias check_content_type_orig check_content_type
  alias check_content_length_orig check_content_length
  alias check_hijack_orig check_hijack
  alias _call_orig _call

  def _call(env)
    @web_socket = env['REQUEST_PATH'] == '/cable'
    _call_orig(env)
  end

  def check_status(status)
    return if @web_socket
    check_status_orig(status)
  end

  def check_headers(headers)
    return if @web_socket
    check_headers_orig(headers)
  end

  def check_content_type(status, headers)
    return if @web_socket
    check_content_type_orig(status, headers)
  end

  def check_content_length(status, headers)
    return if @web_socket
    check_content_type_orig(status, headers)
  end

  def check_hijack(env)
    # Don't know why, but HijackWrapper break WebSocket!
    return if @web_socket
    check_hijack_orig(env)
  end
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71073182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档