From f65e4a8ff006c9aa2f7464b87854538b17dd0c43 Mon Sep 17 00:00:00 2001 From: mrodrigues Date: Wed, 11 Mar 2015 16:50:32 -0300 Subject: [PATCH] Rescuing another type of timeout and limiting timeout to 5 seconds --- Gemfile | 2 +- Gemfile.lock | 31 ++++++++++++++---------- app/services/link_thumbnailer_wrapper.rb | 2 +- config/initializers/link_thumbnailer.rb | 3 ++- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 4b534733..c593b9bd 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'twilio-ruby', '3.14.4' gem 'foundation-rails', '5.5.1.0' gem 'roboto', '0.2.0' gem 'newrelic_rpm', '3.9.9.275' -gem 'link_thumbnailer', '2.5.0' +gem 'link_thumbnailer', '2.5.0', git: 'git://github.com/mrodrigues/link_thumbnailer.git' gem 'acts-as-taggable-on', '3.4.3' gem 'elasticsearch-model', '0.1.6' gem 'elasticsearch-rails', '0.1.6' diff --git a/Gemfile.lock b/Gemfile.lock index b4b1edcf..0ba4d8ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,16 @@ +GIT + remote: git://github.com/mrodrigues/link_thumbnailer.git + revision: cc7b8221ea803ae8eaf2f22d752dd1bae878803b + specs: + link_thumbnailer (2.5.0) + activesupport (>= 3.0) + fastimage (~> 1.6) + json (~> 1.8, >= 1.7.7) + net-http-persistent (~> 2.9) + nokogiri (~> 1.6) + rake (>= 0.9) + video_info (~> 2.4) + GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ @@ -143,7 +156,7 @@ GEM railties (>= 3.0.0) faraday (0.9.1) multipart-post (>= 1.2, < 3) - fastimage (1.6.6) + fastimage (1.6.8) addressable (~> 2.3, >= 2.3.5) ffi (1.9.6) fission (0.5.0) @@ -278,14 +291,6 @@ GEM addressable (~> 2.3) letter_opener (1.3.0) launchy (~> 2.2) - link_thumbnailer (2.5.0) - activesupport (>= 3.0) - fastimage (~> 1.6) - json (~> 1.8, >= 1.7.7) - net-http-persistent (~> 2.9) - nokogiri (~> 1.6) - rake (>= 0.9) - video_info (~> 2.4) mail (2.6.3) mime-types (>= 1.16, < 3) memcachier (0.0.2) @@ -294,7 +299,7 @@ GEM mini_portile (0.6.2) minitest (5.5.1) mixpanel-ruby (1.7.0) - multi_json (1.10.1) + multi_json (1.11.0) multi_xml (0.5.5) multipart-post (2.0.0) mustache (0.99.8) @@ -543,7 +548,7 @@ GEM temple (0.7.5) terminal-table (1.4.5) thor (0.19.1) - thread_safe (0.3.4) + thread_safe (0.3.5) tilt (1.4.1) timecop (0.7.1) timers (4.0.1) @@ -563,7 +568,7 @@ GEM rack raindrops (~> 0.7) vcr (2.9.3) - video_info (2.4.0) + video_info (2.4.1) addressable htmlentities multi_json @@ -617,7 +622,7 @@ DEPENDENCIES jbuilder (= 2.2.6) jquery-rails (= 3.1.2) letter_opener (= 1.3.0) - link_thumbnailer (= 2.5.0) + link_thumbnailer (= 2.5.0)! memcachier (= 0.0.2) mixpanel-ruby (= 1.7.0) newrelic_rpm (= 3.9.9.275) diff --git a/app/services/link_thumbnailer_wrapper.rb b/app/services/link_thumbnailer_wrapper.rb index f64889e2..a0e40042 100644 --- a/app/services/link_thumbnailer_wrapper.rb +++ b/app/services/link_thumbnailer_wrapper.rb @@ -9,7 +9,7 @@ def generate LinkThumbnailer.generate(url) rescue ArgumentError Hashie::Mash.new(title: url, images: [src: url]) - rescue SocketError, Net::HTTP::Persistent::Error + rescue SocketError, Net::HTTP::Persistent::Error, Net::OpenTimeout Hashie::Mash.new(title: url, images: []) end diff --git a/config/initializers/link_thumbnailer.rb b/config/initializers/link_thumbnailer.rb index b316ff16..fa69255e 100644 --- a/config/initializers/link_thumbnailer.rb +++ b/config/initializers/link_thumbnailer.rb @@ -18,7 +18,8 @@ # # See http://www.ruby-doc.org/stdlib-2.1.1/libdoc/net/http/rdoc/Net/HTTP.html#open_timeout # - # config.http_timeout = 5 + config.http_open_timeout = 5 + config.http_read_timeout = 5 # List of blacklisted urls you want to skip when searching for images. #