Search code examples
clojuretravis-cibraintreebraintree-sandbox

Slow Braintree API Requests from Travis CI


I have written a server-side Clojure service that makes use of the Braintree Java SDK. It makes requests to create payment tokens, create customers, handle notifications etc etc. I have a suite of tests written that test all this by making calls to the Braintree sandbox. This all works well, until I try to run the tests on Travis.

On Travis, at least 50% of the time, my build fails because it times out, and I have narrowed down the call to the first call made to the Braintree SDK (which in my case is find customer, but it doesn't seem to matter what call is first). The code sits there for minutes waiting for the call to complete. Sometimes it can happen quickly, other times 10 minutes can pass and the Travis job gives up. This never happens locally.

Does anyone have any idea what's going on? Since it only seems to affect the first call to Braintree, perhaps something to do with the handshaking process? Has anyone else seen this issue?


Solution

  • While it is a shot in the dark, this might be an issue with the build platform lacking good entropy source, and a part of your code and/or dependencies is blocking on reading the random device. If the lack of a good entropy source would be the case, this could be resolved by installing haveged.

    In order to install and start haveged, the use of apt addon is required. Please add the following to your .travis.yml and see if there is any improvement:

    addons:
      apt:
        packages:
          - haveged