Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Heroku、Rails、Resque、Redis:所有作业都因为Errno::ETIMEDOUT而失败_Ruby On Rails_Heroku_Redis_Resque_Redistogo - Fatal编程技术网

Ruby on rails Heroku、Rails、Resque、Redis:所有作业都因为Errno::ETIMEDOUT而失败

Ruby on rails Heroku、Rails、Resque、Redis:所有作业都因为Errno::ETIMEDOUT而失败,ruby-on-rails,heroku,redis,resque,redistogo,Ruby On Rails,Heroku,Redis,Resque,Redistogo,我在heroku上有一个rails应用程序,它使用Resque.enqueu来安排使用Redis和redistogo的后台作业 过去工作正常,但我现在注意到,他们都失败了一段时间(几个星期,100%的工作) 我得到的错误是: 异常Errno::ETIMEDOUT错误连接超时-连接(2) 和堆栈跟踪: > /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `initialize' > /app/vendor/ruby-2.

我在heroku上有一个rails应用程序,它使用Resque.enqueu来安排使用Redis和redistogo的后台作业

过去工作正常,但我现在注意到,他们都失败了一段时间(几个星期,100%的工作)

我得到的错误是:

异常Errno::ETIMEDOUT错误连接超时-连接(2)

和堆栈跟踪:

> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `initialize'
> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `open'
> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `block in
> connect' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/timeout.rb:52:in
> `timeout' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:877:in
> `connect' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:862:in
> `do_start' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:851:in
> `start' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1373:in
> `request' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1131:in
> `get'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:121:in `block in request'
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in
> `block in instrument'
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in
> `instrument'
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in
> `instrument'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:118:in `request'
> /app/vendor/bundle/ruby/2.0.0/gems/shopify_api-4.0.6/lib/active_resource/connection_ext.rb:13:in `request_with_detailed_log_subscriber'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:82:in
> `block in get'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:216:in `with_auth'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:82:in
> `get'
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/custom_methods.rb:57:in
> `get'
> /app/vendor/bundle/ruby/2.0.0/gems/shopify_api-4.0.6/lib/shopify_api/countable.rb:4:in
> `count' /app/app/models/shop.rb:263:in `unscanned_customers'
> /app/app/models/shop.rb:230:in `shopify_customers'
> /app/app/models/shop.rb:144:in `bulk_scan'
> /app/app/workers/bulk_scanner.rb:16:in `perform'
我在想,这可能与没有正确连接Redis或redistogo有关。以下是我拥有的相关初始化器代码:

resque.rb:

Resque.redis = RedisConnection.connection
redis_connection.rb:

class RedisConnection
  def self.close
    connection.quit
  end

  def self.connection
    @connection ||= new_connection
  end

  def self.new_connection
    uri = URI.parse(ENV['REDISTOGO_URL'] || 'redis://localhost:6379/')

    Redis.new(host: uri.host,
              port: uri.port,
              password: uri.password,
              thread_safe: true,
              :timeout => 1)
  end
end

如果在我的应用程序中调用Resque.redis或@connection,它将返回一个redis实例。还有什么会导致此连接错误?哪里可以进行故障排除?

查看回溯,是否可能是Shopify API连接超时? 看起来
unscanned_customers
应该是一个可计数的Shopify集合,当试图检索客户时就会出现问题

我将在这里开始调试:
'count'/app/app/models/shop.rb:263:in
“未扫描的客户”

此外,我将尝试使用专用应用程序API密钥和密码从服务器连接到Shopify:

shop_url = "https://#{API_KEY}:#{PASSWORD}@SHOP_NAME.myshopify.com/admin"
ShopifyAPI::Base.site = shop_url
如有需要,请参阅Shopify API以了解更多详细信息

这将有助于隔离连接问题

干杯