<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,8 @@
 == 3.2.6
 
 * Upgraded to Amalgalite 0.10.0
+* Added an extra Timeout.timeout() loop to all API requests in an attempt to
+  avoid Net::HTTP hanging on server errors
 
 == 3.2.5
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,16 @@ module ScoutAgent
   # Public methods are provided for each action you can perform againt the API.
   # 
   class Server
+    # A custom Exception, used to avoid conflicts with Timeout::Error.
+    class AgentTimeoutError &lt; RuntimeError; end
+    
+    # 
+    # Another Timeout for Net::Http requests.  Their limit doesn't always seem
+    # to trigger in the face of server errors, so we add this redundant check to
+    # avoid hanging on check-in.
+    # 
+    REQUEST_TIMEOUT = 5 * 60
+    
     # 
     # Create a new API wrapper, optionally with a +log+ to write connection
     # details to.
@@ -39,7 +49,7 @@ module ScoutAgent
     # +nil+ is returned if the plan cannot be retrieved for some reason.
     # 
     def get_plan(additional_headers = { })
-      no_warnings {  # keep OpenSSL quiet
+      request {
         @rest_client[&quot;plan.scout&quot;].get(additional_headers)
       }
     rescue Zlib::Error  # could not decompress response
@@ -73,7 +83,7 @@ module ScoutAgent
       gzip =  Zlib::GzipWriter.new(io)
       gzip &lt;&lt; data.to_json
       gzip.close
-      no_warnings do  # keep OpenSSL quiet
+      request do
         @rest_client[&quot;checkin.scout&quot;].post(
           io.string,
           :content_type     =&gt; &quot;application/json&quot;,
@@ -108,7 +118,7 @@ module ScoutAgent
     # the upload succeeded.
     # 
     def post_log(log_file)
-      no_warnings do  # keep OpenSSL quiet
+      request do
         @rest_client[&quot;log.scout&quot;].post(
           log_file.read,
           :content_type     =&gt; &quot;text/plain&quot;,
@@ -128,5 +138,21 @@ module ScoutAgent
       log.warn(&quot;Log could not be sent:  #{error.class}.&quot;)
       false  # could not send log
     end
+  
+    #######
+    private
+    #######
+  
+    # 
+    # A simple helper that silences some OpenSSL warnings and wraps the passed
+    # block in a +REQUEST_TIMEOUT+ limited execution.
+    # 
+    def request
+      no_warnings {  # keep OpenSSL quiet
+        Timeout.timeout(REQUEST_TIMEOUT, AgentTimeoutError) {
+          return yield
+        }
+      }
+    end
   end
 end</diff>
      <filename>lib/scout_agent/server.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6ab2dd340ee98e8119887c8ae67953ee61a7ddff</id>
    </parent>
  </parents>
  <author>
    <name>James Edward Gray II</name>
    <email>james@graysoftinc.com</email>
  </author>
  <url>http://github.com/highgroove/scout_agent/commit/8352c4c78287e05cc59a5d74bb42163ff779067e</url>
  <id>8352c4c78287e05cc59a5d74bb42163ff779067e</id>
  <committed-date>2009-06-29T08:13:21-07:00</committed-date>
  <authored-date>2009-06-29T08:13:21-07:00</authored-date>
  <message>Adding another timeout for API requests in an attempt to work around Net::HTTP's hang on server errors.</message>
  <tree>73b39f380c2bdd6b168da19cfdee3040d66eef7b</tree>
  <committer>
    <name>James Edward Gray II</name>
    <email>james@graysoftinc.com</email>
  </committer>
</commit>
