Mangopay / mangopay2-ruby-sdk

Ruby Gem for MANGOPAY
https://rubygems.org/gems/mangopay
MIT License
42 stars 38 forks source link

Enable changing read_timeout for HTTP requests #27

Closed javiercr closed 9 years ago

javiercr commented 9 years ago

This gem uses the Net::HTTP library to make HTTP requests. By default this library has a read_timeout set to 60 seconds.

As production users of MangoPay API, we've seen how the API sometimes takes more than 60 seconds to respond. This is currently affecting different kind of operations, including PayIn, Refund and Transfers between wallets.

Obviously, having to wait more than 60 seconds for a response from the API is not ideal, but having Net::HTTP firing a timeout is even worse, because when that happens, MangoPay will continue processing the operation, but your app won't ever get noticed of the result, causing multiple kind of issues such as duplicated payments, which means angry customers.

This PR let gem users to increase the timeout of Net::HTTP from MangoPay.configure block:

MangoPay.configure do |c|
  c.read_timeout = 120 # seconds
end
hobailey commented 9 years ago

As discussed via email, I'm closing this thread because the long calls you had was an anomoly and of course not at all normal behaviour, luckily :-)