状況
AWS(EC2)にデプロイしたアプリのお問合せ機能において
お問合せ内容確認画面にて送信ボタンを押すと
表題のエラーが発生します。
ローカル環境では正常に動作しています。
解決方法を教えていただきたく思います。
Chromeで表示されるエラー画面では以下のように表示されます。
Net::OpenTimeout in InquiryController#thanks
お問合せ内容の送信確認画面から送信ボタンを押下すると
inquiryコントローラーのthanksメソッドが呼ばれる仕様になっています。
お問合せ内容は管理人(自分)宛てにメール送信されます。
試したこと
IPv6の無効化を行いましたが解決しませんでした。
環境
Ruby 2.6.6
Rails 5.2.4.4
Unicorn 6.0.0
Nginx 1.16.1
MySQL 8.0.23
関連ファイル
app/controllers/inquity_controller.rb
class InquiryController < ApplicationController
def index
# 入力画面を表示
@inquiry = Inquiry.new
render :action => "index"
end
def confirm
# 入力値のチェック
@inquiry = Inquiry.new(inquiry_params)
if @inquiry.valid?
# OK。確認画面を表示
render :action => "confirm"
else
# NG。入力画面を再表示
render :action => "index"
end
end
def thanks
# メール送信
@inquiry = Inquiry.new(inquiry_params)
InquiryMailer.received_email(@inquiry).deliver
# 完了画面を表示
render :action => "thanks"
end
private
def inquiry_params
params.require(:inquiry).permit(:name, :email, :message)
end
end
~
~
app/views/inquiry/confirm.html.erb
<div class="newWrap">
<div class="newTitle">
<h1>下記内容で送信します。よろしいですか?</h1>
</div>
<div class="confirm-contents">
<%= form_for @inquiry, :url => inquiry_thanks_path do |f| %>
<div class="confirm-items">
<div class="col-sm-4">名前</div>
<div class="col-sm-8"><%= f.hidden_field :name %><%= @inquiry.name %></div>
<div class="col-sm-4">メールアドレス</div>
<div class="col-sm-8"><%= f.hidden_field :email %><%= @inquiry.email %></div>
<div class="col-sm-4">お問い合わせ内容</div>
<div class="col-sm-8"><%= f.hidden_field :message %><%= simple_format(@inquiry.message) %></div>
</div>
<div class="button_wrapper">
<%= f.submit "送信する", class: "btn btn-block btn-success" %>
</div>
<% end %>
</div>
</div>
production.log
~~~~~~~~略
I, [2021-03-25T03:51:10.419286 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Started POST "/inquiry/thanks" for 114.162.4.244 at 2021-03-25 03:51:10 +0000
I, [2021-03-25T03:51:10.419954 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Processing by InquiryController#thanks as HTML
I, [2021-03-25T03:51:10.420022 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Parameters: {"utf8"=>"✓", "authenticity_token"=>"jkuENBblLt6WHV22cqg6HxPHJMrkJXSZEc3xDGcNRb7pWcaxLTxAFKdcIfObc6XyWdwebosBlQ36dWeN/YGvcA==", "inquiry"=>{"name"=>"テスト太郎", "email"=>"[email protected]", "message"=>"test"}, "commit"=>"送信する"}
I, [2021-03-25T03:51:10.424943 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Rendering inquiry_mailer/received_email.html.erb
I, [2021-03-25T03:51:10.425475 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Rendered inquiry_mailer/received_email.html.erb (0.4ms)
I, [2021-03-25T03:51:10.426044 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Rendering inquiry_mailer/received_email.text.erb
I, [2021-03-25T03:51:10.426457 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Rendered inquiry_mailer/received_email.text.erb (0.3ms)
D, [2021-03-25T03:51:10.427877 #3357] DEBUG -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] InquiryMailer#received_email: processed outbound mail in 6.9ms
I, [2021-03-25T03:51:40.444459 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Sent mail to [email protected] (30016.3ms)
D, [2021-03-25T03:51:40.444553 #3357] DEBUG -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Date: Thu, 25 Mar 2021 03:51:10 +0000
From: [email protected]
To: [email protected]
Message-ID: <605c08ae68c71_d1d129b9a855597@ip-10-0-0-81.ap-northeast-1.compute.internal.mail>
Subject: =?UTF-8?Q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF=E6=98=A0=E3=81=88=E3=82=8B=E3=82=93=E5=88=A9=E7=94=A8=E8=80=85=E3=81=8B=E3=82=89=E5=95=8F=E3=81=84=E5=90=88=E3=82=8F=E3=81=9B=E3=81=8C=E3=81=82=E3=82=8A=E3=81=BE=E3=81=97=E3=81=9F?=
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_605c08ae683fa_d1d129b9a8554b3";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_605c08ae683fa_d1d129b9a8554b3
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
------------------------<br>=0D
Name: =E3=82=A2=E3=82=B5=E3=83=8E=E3=83=A4=E3=82=B9=E3=83=92=E3=83=AD<br>=
=0D
Email: [email protected]<br>=0D
Message: aa<br>=0D
-------------------------=
----==_mimepart_605c08ae683fa_d1d129b9a8554b3
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: base64
PGgxPuOBiuWVj+OBhOWQiOOCj+OBm+WGheWuuTwvaDE+DQpOYW1lOiDjgqLj
grXjg47jg6Tjgrnjg5Ljg608YnI+DQpFbWFpbDogbWV6b25nYXdhQGdtYWls
LmNvbTxicj4NCk1lc3NhZ2U6IGFhPGJyPg==
----==_mimepart_605c08ae683fa_d1d129b9a8554b3--
I, [2021-03-25T03:51:40.444733 #3357] INFO -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Completed 500 Internal Server Error in 30025ms
F, [2021-03-25T03:51:40.445191 #3357] FATAL -- : [43d3f26b-4a66-4d78-a817-51cd935f0975]
F, [2021-03-25T03:51:40.445228 #3357] FATAL -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] Net::OpenTimeout (execution expired):
F, [2021-03-25T03:51:40.445259 #3357] FATAL -- : [43d3f26b-4a66-4d78-a817-51cd935f0975]
F, [2021-03-25T03:51:40.445284 #3357] FATAL -- : [43d3f26b-4a66-4d78-a817-51cd935f0975] app/controllers/inquiry_controller.rb:23:in `thanks'
config/environments/production.rb
~~~~~~~~略
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'パブリックIP' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
port: 587,
address: "smtp.gmail.com",
domain: "gmail.com",
user_name: ENV["SMTP_USERNAME"],
password: ENV["SMTP_PASSWORD"],
authentication: "plain",
enable_starttls_auto: true,
}