代码之家  ›  专栏  ›  技术社区  ›  good_afternoon

RubyonRails:操作正在进行中-connect(2)将阻塞

  •  0
  • good_afternoon  · 技术社区  · 5 年前

    我在一个别人做的网站上工作。有一个生产版本。

    我试着给30天没更新过的用户发邮件。

    在我试着使用之前,一切都是有效的 deliver_later . 我使用的原因 是因为 deliver_now 导致每秒发送过多电子邮件的问题。我目前正在使用Mailtrap进行测试,但我想我会在生产中遇到这种问题。

    所以我选择了等待一秒钟的每封电子邮件:

          @testproperties = Property.has_not_updated.includes(:user)
          @testproperties.each do |property|
              UserMailer.with(property: property, user: property.user).check_listing.deliver_later(wait:1.seconds)
          end
    

    IO::EINPROGRESSWaitWritable Operation now in progress - connect(2) would block

    什么也发不出来。

    编辑: 我可以在生产现场看到,我可以参观路线/sidekiq。路由文件具有以下块:

      authenticate :user, lambda { |u| u.admin? } do
        mount Sidekiq::Web => '/sidekiq'
      end
    

    我可以查看web界面并查看所有作业。一切都在那工作。但我需要访问运行在上的开发版本 localhost:3000

    尝试在本地访问此文件仍会导致:

      #  # Socket#connect
      def connect_nonblock(addr, exception: true)
        __connect_nonblock(addr, exception)
      end
    end
    

    赛德基克.rb:

    require 'sidekiq'
    
    unless Rails.env.test?
      host = 'localhost'
      port = '6379'
      namespace = 'sitename'
    
      Sidekiq.configure_server do |config|
        config.redis = { url: "redis://#{host}:#{port}", namespace: namespace }
        schedule_file = "config/schedule.yml"
        if File.exists?(schedule_file)
          Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
        end
        config.server_middleware do |chain|
          chain.add Sidekiq::Status::ServerMiddleware, expiration: 30.minutes
        end
        config.client_middleware do |chain|
          chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes
        end
      end
    
      Sidekiq.configure_client do |config|
        config.redis = { url: "redis://#{host}:#{port}", namespace: namespace }
        config.client_middleware do |chain|
          chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes
        end
      end
    end
    

    为电缆.yml:

    development:
      adapter: async
      url: redis://localhost:6379/1
      channel_prefix: sitename_dev
    
    test:
      adapter: async
    
    production:
      adapter: redis
      url: redis://localhost:6379/1
      channel_prefix: sitename_production
    
    
    0 回复  |  直到 5 年前
        1
  •  5
  •   David Buck Richard Ferris    4 年前

    生产服务器正在运行Ubuntu,他们已经安装了 redis-server .

    我没有在本地安装。(我通过Windows WSL使用Ubuntu)

    sudo apt install redis-server
    

    我现在可以访问web界面了。