-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: OpenSearch ConnectionError(Timeout context manager should be used inside a task) #13358
Comments
The error you're encountering, "ConnectionError(Timeout context manager should be used inside a task)," suggests that the asynchronous operation with OpenSearch is being executed outside of an async function or context. To resolve this, ensure your code interacts with OpenSearch within an async context. Here's a structured approach:
Here's an example to guide you: import asyncio
from opensearchpy import AsyncOpenSearch
async def query_opensearch():
opensearch_url = 'http://localhost:9200' # Replace with your details
async with AsyncOpenSearch(
opensearch_url,
http_compress=True, # Optional
) as client:
response = await client.search(index="index_name", body={"query": {"match_all": {}}})
print(response)
if __name__ == "__main__":
asyncio.run(query_opensearch()) This code demonstrates the correct way to perform asynchronous operations with OpenSearch, ensuring they're executed within an async context to avoid the "ConnectionError" you're experiencing. For further troubleshooting, especially if adapting the code doesn't resolve the issue, providing more context about your execution environment (e.g., script, Jupyter notebook) could help identify additional factors contributing to the problem.
|
Is this a timeout? your traceback just shows some connection error? |
Connection issues should not be a problem. Everything is run locally at this stage and I check the health of the OpenSearch cluster before doing anything
It rather looks like some sort of async error in the library |
Hey @chrfthr, Did you mange to solve the issue by any chance? I'm facing the exact same issue. Traceback:
|
Bug Description
After upgrading from 0.9.3 I get a connection error when querying my OpenSearch vectorstore. I'm not sure if I should post this here or open an opensearch-py issue..
I have llama-index installed in the following conda environment with Pyhton 3.10.0:
channels:
dependencies:
Version
0.13.34
Steps to Reproduce
Query a RetrieverQueryEngine built from a VectorIndexRetriever, a VectorStoreIndex and an OpensearchVectorStore. I implemented a custom version of the VectorIndexRetriever, but this should not be relevant as the error also appeared when using the library retriever. The custom vector retriever is also wrapped in a custom retriever.
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: