Share via

Got ImageAnalysisErrorReason.CONNECTION_FAILURE when calling imageAnalysis api from python.

HAOCHEN BAI 5 Reputation points
2024-01-18T07:23:38.42+00:00

I am using imageAnalysis, mainly trying to use ocr to get text from image. I followed this tutorial and everything worked perfectly until recently.
https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/quickstarts-sdk/image-analysis-client-library-40?tabs=visual-studio%2Clinux&pivots=programming-language-python

My code worked before and I made no change but suddenly got the following error:

Analysis failed.
Error reason: ImageAnalysisErrorReason.CONNECTION_FAILURE
Error code: 3
Error message: Failed with error: HTTPAPI_OPEN_REQUEST_FAILED [0x3 | 2550]
POST https://xxxx.cognitiveservices.azure.com/computervision/imageanalysis:analyze?api-version=2023-02-01-preview&features=read

I am using this inside docker in my aws EC2 server. I installed the lastest version azure-ai-vision==0.15.1b1 I can use curl to call rest-api of the same resource and get successful response inside the docker container so I guess there should be no problem with connection or firewall problems.

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

3 answers

Sort by: Most helpful
  1. HAOCHEN BAI 5 Reputation points
    2024-01-22T07:42:15.68+00:00

    @Rohit Mungi Thank you so much for the information. I have already shifted from Python SDK to RESTFUL API to solve this problem. I saw on the SDK document page that Microsoft is warning that 4.0 SDK is still not in stable status, so I decide to use RESTFUL API from now on. Anyway, really thanks for all the help!

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Rohit Mungi 49,131 Reputation points Microsoft Employee Moderator
    2024-01-22T07:35:34.6966667+00:00

    @HAOCHEN BAI A recent issue with same error is reported by a different user and a fix is expected in next iteration of SDK later this month or early february. https://github.com/Azure-Samples/azure-ai-vision-sdk/issues/64 Please see above thread and try to use the REST API till the same is fixed in newer version of the SDK. Thanks!!

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  3. AI answer

    2024-01-18T07:23:38.4233333+00:00

    The error message you received indicates a connection failure when calling the Image Analysis API. This could be due to a variety of reasons, such as network issues or server problems. Since you mentioned that you can successfully call the REST API using curl from within the Docker container, it's possible that the issue is related to the SDK or the Python package you're using.

    To troubleshoot this issue, you can try the following steps:

    1. Check if there are any updates available for the azure-ai-vision package and update it if necessary.
    2. Try running your code outside of the Docker container to see if the issue persists.
    3. Check if there are any logs or error messages that can provide more information about the connection failure.
    4. If none of the above steps work, you can try reaching out to Microsoft support for further assistance.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.