I'm trying to use the Google Cloud Vision REST API to detect explicit content in user-submitted images, but am finding that requests are randomly failing for no apparent reason. Instead of receiving an error response, the request is just hanging and eventually the PHP process is timing out after 30 seconds.
Steps to replicate:
1. Download the example image (don't worry, this image IS safe for work!).
2. Base64-encode the image.
3. Create a file called request.json containing the following contents:
{
"requests": [
{
"image": {
"content": "insert base64-encoded image data here"
},
"features": [
{
"type": "SAFE_SEARCH_DETECTION"
}
]
}
]
}
4. Send the following CURL request several times:
curl -X POST -H "Content-Type: application/json; charset=utf-8" -d @request.json "https://vision.googleapis.com/v1/images:annotate?key=API_KEY"
What I'm finding is that while some requests succeed and return a response, many requests fail as described above with no error, just a timeout. It's like the request is completely ignored. Some images seem more susceptible to this issue than others – the ones that have been most problematic are the NSFW images I've been testing with, so I'm obviously reluctant to share them on this forum!
I've checked in the API console and am nowhere near close to hitting any of the quotas.
Any advice on what might be causing this issue would be much appreciated!
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |