PhantomJS在JENKINS中间歇性地抛出错误 - 连接被拒绝等

时间:2016-02-02 16:00:00

标签: ruby jenkins selenium-webdriver cucumber capybara

我在Jenkins非常间歇性地收到以下错误,其中最新的错误发布在下面。我以前从未见过这个问题。一些开发人员使用CSS推送了一些CSS3更改,这是我开始收到错误的时候。我正在使用phantomjs version - 1.9.8。有什么想法吗?

Connection refused - connect(2) for "127.0.0.1" port 8910 (Errno::ECONNREFUSED)
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:879:in `open'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
      /opt/chefdk/embedded/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
      /opt/chefdk/embedded/lib/ruby/2.1.0/timeout.rb:101:in `call'
      /opt/chefdk/embedded/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:878:in `connect'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:852:in `start'
      /opt/chefdk/embedded/lib/ruby/2.1.0/net/http.rb:1375:in `request'

1 个答案:

答案 0 :(得分:0)

我假设您每次都遇到此错误,然后您需要更新Jenkins上的Selenium Standalone服务器。

如果您间歇性地面对此问题,那么您也可以尝试重启phantomjs

def restart_phantomjs
        puts "-> Restarting phantomjs: iterating through capybara sessions..."
        session_pool = Capybara.send('session_pool')
        session_pool.each do |mode,session|
          msg = "  => #{mode} -- "
          driver = session.driver
          if driver.is_a?(Capybara::Poltergeist::Driver)
            msg += "restarting"
            driver.restart
          else
            msg += "not poltergeist: #{driver.class}"
          end
          puts msg
        end
      end
      module_function :restart_phantomjs
 end