Capybara/Poltergeist "web_socket_server error" 在 "initialize" 上:权限被拒绝

Capybara/Poltergeist "web_socket_server error" on "initialize": permission denied

我正在尝试使用 Ruby 1.9.3 应用程序(不是 rails 或网络)在 Openshift 中进行 运行 Capybara/PhantomJS 测试。它在本地运行良好,但是当我尝试 bundle exec ruby test.rb 它输出:

/var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `initialize': Permission denied - bind(2) (Errno::EACCES)
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `open'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `start_server'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:26:in `initialize'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:20:in `new'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:20:in `start'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:8:in `initialize'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:38:in `new'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:38:in `server'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:25:in `browser'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:95:in `visit'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/capybara-2.5.0/lib/capybara/session.rb:232:in `visit'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/capybara-2.5.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
    from test.rb:43:in `test'
    from test.rb:58:in `<main>'

我正在使用 Poltergeist 并手动将其指向 Poltergeit's github 中看到的 phantomjs 可执行文件(从该页面获得的 exec,v1.98),它本身似乎工作正常并且具有适当的可执行文件特权。它位于与 ruby 项目相同的目录中,因此 poltergeis 的 :phantomjs 选项是 ./phantomjs.

我从输出中看到vendor/bundle中的Ruby版本是1.9.1,根据Capybara的github不支持,但我不确定这是否相关的。

知道这里可能有什么问题,或者如何更好地调试这个错误吗?

看起来您的应用程序(或其中的某些部分)正在尝试绑定到不允许的 IP 地址或端口。您只能绑定到您的 openshift ip 地址(不是 0.0.0.0 或 127.0.0.1)并且您的应用程序应该绑定到端口 8080 以便它可以公开访问。您可以参阅开发人员门户的此部分 (https://developers.openshift.com/en/managing-port-binding-routing.html),了解有关如何将请求路由到您的应用程序的更多信息。