Curl Timeout Errors

I keep getting intermittent curl timeout errors. There seems to be now rhyme or reason to when it happens.
Is any one else experiencing this, and does any one have any ideas on how to solve the problem?
Thanks
Cloudy

What are you curling?

There tend to be intermittent network issues with various third party services, registries, repos, etc…

Well it often happens with my browser tests that are using curl to access a page in the system, but that can usually be dealt with by making the test wait until the curl get a response.
In the specific case that brought this up again it was curling
curl http://programs.dev/?rs_clear_database_and_seed=true
Which is a call to our wordpress that clears and seeds the database.
If wonder if there is anything we can do about that, or will I have to write a little shell script that retires until the curl passes. We have a script you guys helped us with for a different curl call, maybe that can be repurposed.
I can’t seem to find it right now, but it was something like this psuedocode.

curl try-the-url
if the response is not 200
keep trying until it is

the curl we perform is internal, calling the host we define early on in setting up the machine. It fails about 5% of the time. don’t know why.

Here is the solution that will get these curls to pass.
This follows the same logic as the psuedo code I wrote in the OP, but it actually works :slightly_smiling:

URL=http://your-url.dev RESPONSE=$(curl --write-out "%{http_code}\n" --silent --output /dev/null "$URL") while [ $RESPONSE -ne 200 ] do RESPONSE=$(curl --write-out "%{http_code}\n" --silent --output /dev/null "$URL") done
I found that the correct response will probably be 302 if the url is a redirect, so watch out for that