1

I'm getting this error when triggered by mail using the deliver-later method using the postmark-mailer gem in Rails.

2022-09-13T12:03:19.061Z 45075 TID-osgak45wb PostmarkMailer::DeliveryJob JID-031252f83654da580e4d3fcf INFO: start
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb PostmarkMailer::DeliveryJob JID-031252f83654da580e4d3fcf INFO: fail: 0.131 sec
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"PostmarkMailer::DeliveryJob","queue":"mailers","args":[{"job_class":"PostmarkMailer::DeliveryJob","job_id":"08138389-7cc8-4f0a-84c8-4cfbe0869cf4","provider_job_id":null,"queue_name":"mailers","priority":null,"arguments":[{]},\"track_opens\":\"true\",\"_aj_symbol_keys\":[\"from\",\"to\",\"template_id\",\"template_model\",\"track_opens\"]}],\"executions\":0,\"locale\":\"en\"}],\"retry\":true,\"jid\":\"031252f83654da580e4d3fcf\",\"created_at\":1663065224.6059873,\"enqueued_at\":1663070599.0592043,\"error_message\":\"SSL_connect returned=1 errno=0 state=error: no protocols available\",\"error_class\":\"OpenSSL::SSL::SSLError\",\"failed_at\":1663065241.922269,\"retry_count\":7,\"retried_at\":1663068011.4937775}"}
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb WARN: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: no protocols available
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb WARN: ~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/protocol.rb:44:in `connect_nonblock'
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb WARN: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: no protocols available
2022-09-13T12:03:19.192Z 45075 TID-osgak45wb WARN: ~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/protocol.rb:44:in `connect_nonblock'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/protocol.rb:44:in `ssl_socket_connect'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:996:in `connect'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:930:in `do_start'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:919:in `start'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:1470:in `request'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:1493:in `send_entity'
~/.rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/net/http.rb:1281:in `post'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/http_client.rb:30:in `block in post'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/http_client.rb:86:in `block in do_request'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/http_client.rb:85:in `synchronize'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/http_client.rb:85:in `do_request'
~.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/http_client.rb:30:in `post'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/api_client.rb:244:in `block in deliver_with_template'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/client.rb:39:in `with_retries'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/postmark-1.14.0/lib/postmark/api_client.rb:243:in `deliver_with_template'
~/.rvm/gems/ruby-2.6.4@orbidal/bundler/gems/postmark_mailer-152b64d07df2/lib/postmark_mailer/message_delivery.rb:13:in `deliver_now'
~/.rvm/gems/ruby-2.6.4@orbidal/bundler/gems/postmark_mailer-152b64d07df2/lib/postmark_mailer/delivery_job.rb:8:in `perform'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/activejob-5.1.6/lib/active_job/execution.rb:37:in `block in perform_now'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
~/.rvm/gems/ruby-2.6.4@orbidal/gems/i18n-1.1.1/lib/i18n.rb:284:in `with_locale'

This is my Ruby and OpenSSL environment:

Ruby:           2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]
RubyGems:       3.0.3
Bundler:        2.2.25
Compiled with:  OpenSSL 1.1.1f  31 Mar 2020
Loaded version: OpenSSL 1.1.1f  31 Mar 2020
SSL_CERT_FILE:  /usr/lib/ssl/cert.pem
SSL_CERT_DIR:   /usr/lib/ssl/certs

With that out of the way, let's see if you can connect to rubygems.org…

Bundler connection to rubygems.org:       success ✅
RubyGems connection to rubygems.org:      success ✅
Ruby net/http connection to rubygems.org: success ✅

Hooray! This Ruby can connect to rubygems.org. You are all set to use Bundler and RubyGems.
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • Can you also share all your postmark settings? Of course, with the sensitive information masked. – kevinluo201 Sep 20 '22 at 04:13
  • Sure @kevinluo201, Here is the postmark config we have implemented: PostmarkMailer.configure do |config| config.api_key = Rails.application.secrets.postmark_api_token config.default_delivery_queue = :mailers end – Nikita Sharma Oct 17 '22 at 07:36

2 Answers2

0

Insert the following code into your application_controller.rb file on line 1:

OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
0

This fixes the problem:

First, check the Rails version and its compatibility with Sidekiq. If compatible, then run these commands:

rvm get head
rvm pkg remove
rvm requirements run 
rvm reinstall [ruby version you need]

If not compatible, then check for a compatible version of Ruby or Sidekiq.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303