Getting AlgoliaUnreachableHostException("Unreachable hosts") when attempting to upload records via AWS Lambda
还没有人认领这个 Issue。
评估
调研方向
从 algoliasearch/http/transporter.py 开始,特别关注从 save_objects 进入的重试路径,并使用指定的 Python 和客户端版本在 AWS Lambda 中复现所提供的示例。将 Lambda 执行与本地上传进行比较,并验证有效记录可以在不出现 AlgoliaUnreachableHostException 的情况下上传。
由索引模型根据 Issue 内容生成。
描述
- Algolia Client Version: 2.5.0
- Language Version: Python
Description
I am facing a similar issue as reported in this Past Issue - https://github.com/algolia/algoliasearch-client-python/issues/30.
StackTrace -
raise AlgoliaUnreachableHostException("Unreachable hosts") in retryst)fNotExist": True})
END RequestId: 0d549eca-dd2e-4884-9f43-0548a6db3674
REPORT RequestId: 0d549eca-dd2e-4884-9f43-0548a6db3674 Init Duration: 0.46 ms Duration: 4491.58 ms Billed Duration: 4500 ms Memory Size: 1024 MB Max Memory Used: 1024 MB
{"errorMessage": "Unreachable hosts", "errorType": "AlgoliaUnreachableHostException", "stackTrace": [" File \"/var/task/main.py\", line 37, in lambda_handler\n scan_and_upload_to_algolia()\n", " File \"/var/task/ddb_utils.py\", line 72, in scan_and_upload_to_algolia\n update_templates_data_in_algolia(algolia_records)\n", " File \"/var/task/algolia_utils.py\", line 21, in update_templates_data_in_algolia\n res = templates_v4_index.save_objects(records, {\"autoGenerateObjectIDIfNotExist\": True})\n", " File \"/var/task/algoliasearch/search_index.py\", line 69, in save_objects\n response = self._chunk(\"addObject\", objects, request_options, False)\n", " File \"/var/task/algoliasearch/search_index.py\", line 527, in _chunk\n raw_responses.append(self._raw_batch(requests, request_options))\n", " File \"/var/task/algoliasearch/search_index.py\", line 534, in _raw_batch\n return self._transporter.write(\n", " File \"/var/task/algoliasearch/http/transporter.py\", line 35, in write\n return self.request(verb, hosts, path, data, request_options, timeout)\n", " File \"/var/task/algoliasearch/http/transporter.py\", line 72, in request\n return self.retry(hosts, request, relative_url)\n", " File \"/var/task/algoliasearch/http/transporter.py\", line 94, in retry\n raise AlgoliaUnreachableHostException(\"Unreachable hosts\")\n"]}%
Code Snippet
def create_algolia_client():
algolia_api_key = os.environ.get("INVIDEO_ALGOLIA_API_ID").strip()
algolia_api_id = os.environ.get("INVIDEO_ALGOLIA_API_KEY").strip()
if algolia_api_id is not "" and algolia_api_key is not "":
algolia_client = SearchClient.create(algolia_api_id, algolia_api_key)
logger.info("algolia search client created")
return algolia_client
else:
logger.error("algolia id and key is missing, failed to create insights client")
def update_templates_data_in_algolia(records):
algolia_client = create_algolia_client()
templates_v4_index = algolia_client.init_index("templates_v4")
res = templates_v4_index.save_objects(records, {"autoGenerateObjectIDIfNotExist": True})
logger.info("Got Response from Algolia", res)
I am running this code snippet inside AWS Lambda.
After reading the possible solutions in past Issue. I added urllib3, requests[security] and pyOpenSSL libraries.
Here's the pyproject.toml -
python = "3.8.5"
algoliasearch = "^2.5.0"
urllib3 = "^1.26.6"
requests[security] = 2.9.1
pyOpenSSL = 20.0.1
We have performed following checks -
- Api ID and Key are valid, were able to upload records from Local.
- Record Object is valid.
- Our Lambda is not in any VPC.
- Ensured our Lambda is able to resolve Algolia Server by performing DNS Lookup on .algolia.net.
Steps To Reproduce
- Run the provided snippet inside AWS Lambda with above configuration for python.
- Pass any valid record object and replace ID and Key with a valid one.
- 主要语言
- Python
- 星标
- 207
- 派生
- 63
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
algolia/algoliasearch-client-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
Version 4.31.0 introduced breaking urllib3 dependency constraint incompatible with other packages未关闭
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 25/100
algolia/algoliasearch-client-python#565 · 1 条评论 · 2 个 reaction ·
查看 algolia/algoliasearch-client-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
volcengine/OpenViking#8432 ·
维护者通常 1 天内回复
-
Failed chat turns are passed to the follow-up rewrite as completed history可能已有人在做 @hskhyl 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
NVIDIA/auto-ontology#683 · 1 条评论 ·
维护者通常 1 天内回复
-
documentation task
难度 2/5 1-3 小时 新手友好度 62/100
-
Implement parse_url and accept http URLs for Pear backend可能已有人在做 @muskan-creates352 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
fedora-infra/anitya#2231 ·
维护者通常 2 天内回复
-
MarkdownDocSerializer.post_process escapes '\<' to '\<', rendering literal '<' in CommonMark未关闭
难度 2/5 1-3 小时 新手友好度 74/100
docling-project/docling-core#1067 ·
维护者通常 3 天内回复