Flaky SocketTimeoutExceptions with Karate tests

Viewed 721

Fairly new to Karate. I'm trying to debug a few tests that have been intermittently failing with SocketTimeoutExceptions. I usually see something like:

com.intuit.karate.exception.KarateException: -unknown-:16 - 
create-identity.feature:23 - 
java.net.SocketTimeoutException: Read timed out
    at ✽.* def associatedUserIdentity = call read('classpath:services/shared/create-identity.feature')

The strange part is that the tests pass on the first run, but if I repeat the tests they start hanging and I see these errors.

We have connectTimeout and readTimeout set to 30000 if that's useful.

The endpoints return 200 OK within a couple of seconds when I manually test them using a REST client so I'm thinking there might be something wrong with our Karate configuration.

Any help would be greatly appreciated.

2 Answers

We also faced this issue, and as it a very sporadic issue, it's hard to share steps to reproduce. A work around that worked for us in most of the cases is to reduce the the threadCount in the runner to 1: final Results stats = AgentRunner.parallel(getClass(), 1, KARATE_OUTPUT_PATH);

Related