6

I'm working on a site someone else made. There is a production version.

I'm trying to send emails to users whose properties haven't been updated in 30 days.

Everything works until I try to use deliver_later. The reason I'm using deliver_later is because deliver_now results in an issue of sending too many emails per second. I'm currently using Mailtrap for testing, but I assume I will run into that sort of issue on production.

So I opted to wait 1 second for each email:

      @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

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

And nothing sends.

I'm not sure how to solve this issue.

Edit: I can see on the production site that I can visit the route /sidekiq. The routes file has this block:

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

I can view the web interface and see all the jobs. It's all working there. But I need to access development version running on localhost:3000.

Trying to access this locally still results in:

Operation now in progress - connect(2) would block

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

Sidekiq.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

for cable.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

2 Answers 2

21

The production server is running Ubuntu and they already installed redis-server.

I had not installed that locally. (I'm using Ubuntu through Windows WSL)

sudo apt install redis-server

I can now access the web interface.

1
  • 6
    I was in the exact same situation and this was the issue! Installed and started the redis-server service in my WSL environment and it worked. Thanks! May 15, 2020 at 3:36
0

Make sure that Redis is started:

 sudo service redis-server restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.