premailer-rails: Can't run premailer on separate queue server
I’ve split my Rails production server into two: a background server that runs redis/sidekiq and a frontend server running unicorn/rails.
If I schedule an email delivery using the Mailer.action(args).deliver_later then it fails with Failed to open TCP connection to :80 (i.e. it’s setting the host to be the empty string).
See below for a manually triggered example in the rails console on the queue server. The queue server has the same code as the web server but there’s no unicorn/nginx web service running on 80/443.
irb(main):001:0> Mailer.activation_reminder('sean.handley@gmail.com').deliver_now
Rendering mailer/activation_reminder.html.erb
Rendered mailer/_header.html.erb (0.7ms)
Rendered mailer/_footer.html.erb (0.5ms)
Rendered mailer/activation_reminder.html.erb (9.5ms)
Mailer#activation_reminder: processed outbound mail in 603.9ms
Errno::ECONNREFUSED: Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80)
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:878:in `connect'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:852:in `start'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:584:in `start'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:479:in `get_response'
from /home/rails/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:456:in `get'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_loaders/network_loader.rb:9:in `load'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_helper.rb:41:in `block in load_css'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_helper.rb:40:in `each'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_helper.rb:40:in `load_css'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_helper.rb:21:in `css_for_url'
from /home/rails/stronghold/vendor/bundle/ruby/2.3.0/gems/premailer-rails-1.9.3/lib/premailer/rails/css_helper.rb:17:in `block in css_for_doc'
I’ve tried setting the base_url for premailer via the docs recommendation but it makes no difference.
Any ideas how to further debug and fix would be great!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Because premailer-rails fails on the queue node. https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by deleted user 7 years ago
- Because premailer-rails fails on the queue node. https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by deleted user 7 years ago
- Because premailer-rails fails on the queue node. https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by deleted user 7 years ago
- Because premailer-rails fails on the queue node. https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by deleted user 7 years ago
- Because premailer-rails fails on the queue node. https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by deleted user 7 years ago
- Because premailer-rails fails on the queue node. (#335) https://github.com/fphilipe/premailer-rails/issues/182 — committed to seanhandley/stronghold by seanhandley 7 years ago
Got it - the stylesheet URL was wrong. All seems to be working fine now. Thanks for the help!