From d7dd63ae4a99606f1be12624e9bddf76b49b64a6 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 18 Dec 2014 08:40:38 +0100 Subject: [PATCH] Added timeout options for Faraday. --- lib/geo_ip/freegeoip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/geo_ip/freegeoip.rb b/lib/geo_ip/freegeoip.rb index cdf25a643..d3158734e 100644 --- a/lib/geo_ip/freegeoip.rb +++ b/lib/geo_ip/freegeoip.rb @@ -16,7 +16,7 @@ class GeoIp::Freegeoip url = "/json/#{CGI::escape address}" data = {} begin - conn = Faraday.new( :url => host ) + conn = Faraday.new( :url => host, :options => { :open_timeout => 2, :timeout => 5 } ) response = conn.get url data = JSON.parse( response.body ) Cache.write( cache_key, data, { :expires_in => 90.days } )