AWS::S3 connection timeout

This morning our servers were having problems uploading photos to Amazon S3. After poking around a bit, I discovered that the connections were only sporadically failing- most of the time they worked, but the few that were not tied up all the available processes.

Unfortunately the aws/s3 gem does not allow you to specify timeouts as options, so I had to hack up the gem source code itself. I added to the create_connection method in /usr/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb


http.open_timeout = 1
http.read_timeout = 5

That seems to have cleared things up for now.

Trying to get Rails to work with Ruby 1.9 again. Kept getting the error

ArgumentError (invalid byte sequence in US-ASCII):

Sticking this at the top of environment.rb seems to have fixed it:

if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end

Found the solution here.