I find that I run into Net::HTTP and Net::FTP problems like this periodically, and when I do, surrounding the call with a timeout() makes all of those issues vanish. So where this will occasionally hang for 3 minutes or so and then raise an EOFError:
res = Net::HTTP.post_form(uri, args)
This always fixes it for me:
res = timeout(120) { Net::HTTP.post_form(uri, args) }