0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rubyの通信処理におけるopensslのエラー

Last updated at Posted at 2020-03-10

■ 背景

Slack通知が来なくなったので気づいたのですが、Ruby使って実行しているBatch処理における通信部分がコケていたのでその原因調査したメモです。

■ 目次

  1. 環境
  2. 事象
  3. やったこと
  4. まとめ
  5. 参考サイト

■ 内容

1. 環境

$ rbenv -v
rbenv 1.1.2-26-gc6324ff
$ rbenv versions
  system
* 2.5.1 (set by /Users/y-agatsuma/.rbenv/version)
$ bundler -v
Bundler version 1.16.2
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
$ bundle exec gem list | grep slack
slack-incoming-webhooks (0.3.0)

2. 事象

SSL_connect returned=1 errno=0 state=error: tlsv1 alert protocol version
Traceback (most recent call last):
	23: from app/controllers/scout_actions/execute_bot_periodically.rb:84:in `<main>'
	22: from app/controllers/scout_actions/execute_bot_periodically.rb:41:in `start'
	21: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:264:in `y-agatsuma'
	20: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:358:in `work_in_processes'
	19: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:418:in `create_workers'
	18: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:418:in `each_with_index'
	17: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:418:in `each'
	16: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:419:in `block in create_workers'
	15: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:428:in `worker'
	14: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:428:in `fork'
	13: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:437:in `block in worker'
	12: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:455:in `process_incoming_jobs'
	11: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/parallel-1.12.1/lib/parallel.rb:484:in `call_with_index'
  
  # <----- 何かしら処理 ----->
  
	 6: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/slack-incoming-webhooks-0.2.0/lib/slack/incoming/webhooks/request.rb:11:in `post'
	 5: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:1455:in `request'
	 4: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:909:in `start'
	 3: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:920:in `do_start'
	 2: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/http.rb:981:in `connect'
	 1: from /Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/protocol.rb:44:in `ssl_socket_connect'
/Users/y-agatsuma/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/protocol.rb:44:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: tlsv1 alert protocol version (OpenSSL::SSL::SSLError)

上記は、並列で何かしらの処理を実行した最後に、slack-incoming-webhooksというgemを使って
Slackに通知を送信する部分の処理で発生してる模様。

他にも調べてみると通信全般でエラーが発生していました。

3. やったこと

■ rbenv/ruby-buildを最新化したら治るんじゃね? → ダメ

$ brew upgrade ruby-build
$ 処理実行 → ダメ

■ rubyをバージョンアップしたらいけるんじゃね?

1. ruby2.7.0にして、古いbunlderのままで実行してみる → ダメ
$ rbenv install 2.7.0
$ rbenv global 2.7.0
$ rbenv rehash
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
$ rbenv exec gem install bundler -v 1.16.2
$ 処理実行 → ダメ
2. ruby2.7.0にして、bundlerをdefalut(=2.1.2)に変更して実行してみる → イケた
$ rbenv exec gem uninstall bundler
→ 古いやつ(1.16.2)をアンインストール
$ rbenv exec gem list | grep bundler
bundler (default: 2.1.2)
# Gemfile.lockを削除してから、再度 $ bundle installしてあげて
$ 処理実行 → イケた

4. まとめ

  • Rubyのバージョンというよりも、bundlerに付随するエラーだった模様
  • bundlerをアップデートして、Gemfile/Gemfile.lockを更新したら直ったった

5. 参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?