braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 98 forks source link

Inability to change read or connection timeouts #36

Closed marotti closed 8 years ago

marotti commented 8 years ago

It appears that the read timeout is hard coded in the com.braintreegateway.util.Http. buildConnection(...), line 177.

Unfortunately, 1 minute timeouts are unacceptable with the project with which I am using this client. I'm assuming it would have the most usability to have this default value put in the Configuration object with the ability to change it if needed.

raymondberg commented 8 years ago

Thanks for the suggestion, @marotti! If I understand you, you'd like to tighten up the timeout to something below 60 seconds (as the gateway will timeout anything over 60 seconds). You're right, this would be really handy in the Java library. We'll look at what it will take to get this implemented. We'll let you know when we have updates.

omgrr commented 8 years ago

We just released a new version of the library where you can set the timeout. Keep in mind when setting the timeout that the Braintree gateway currently has a timeout of 60 seconds to accomadate long requests. However, if you set the timeout for less than 60 seconds you may not see the result.

For example, if you set the server SDK timeout to 10 seconds and the request successfully charges the customer at the processor after 19 seconds, then the customer will be charged for the transaction and you will not be notified of this. You will need to check the state of the transaction in the gateway to verify whether the transaction was successful or not.

private static BraintreeGateway gateway = new BraintreeGateway(
  Environment.SANDBOX,
  "your_merchant_id",
  "your_public_key",
  "your_private_key"
);
gateway.configuration.setTimeout(10000);

If you have any issues please feel free to reach out to us, thanks again for bringing this up!