algolia / algoliasearch-client-python

⚡️ A fully-featured and blazing-fast Python API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/python/?language=python
MIT License
196 stars 67 forks source link

Update AlgoliaUnreachableHostException to OperationTimeout #556

Open dylancaponi opened 1 year ago

dylancaponi commented 1 year ago

Description

Client throws algoliasearch.exceptions.AlgoliaUnreachableHostException: Unreachable hosts during replace_all_objects operation. The issue was not that hosts were unreachable but that the operation was timing out. I fixed the problem by setting readTimeout to 100:

client = SearchClient.create(algolia_application_id, algolia_api_key)
index = client.init_index(algolia_index)
request_options = {
    "readTimeout": 100
}
index.replace_all_objects(records, request_options)

A timeout should produce a timeout error. Unreachable is misleading.

Steps To Reproduce

See description. Use replace_all_objects on a sufficiently big index. Mine was 6393 rows and 10+ columns some with significant text blocks.

shortcuts commented 1 year ago

Hey, thanks for the issue! We throw an unreachable host error because after a timeout error, we will try an other host (Algolia's API offers multiple), then if there's no host left we end up in an AlgoliaUnreachableHostException

I can however confirm that it can be misleading when doing large enough operations

dylancaponi commented 7 months ago

I'm now seeing this error regardless how big I set the readTimeout. I've triple checked App ID and API Key.

dylancaponi commented 7 months ago

Oh, you also get this message if the index does not exist. I would expect index does not Exist rather than an unreachable hosts error...