Azure-Samples / azure-ai-vision-sdk

SDK for Microsoft's Azure AI Vision
MIT License
76 stars 46 forks source link

ImageAnalysisErrorReason.CONNECTION_FAILURE #40

Closed lordlinus closed 1 year ago

lordlinus commented 1 year ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request
- [X ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

run the sample code from the documentation page at https://github.com/Azure-Samples/azure-ai-vision-sdk/blob/main/docs/learn.microsoft.com/python/image-analysis/3/main.py endpoint used format - https://{name_of_cogs_service}.cognitiveservices.azure.com/ valid api key is used - the below curl request from the same pc works fine

curl -X POST "https://{name_of_cogs_service}.cognitiveservices.azure.com/computervision/imageanalysis:analyze?api-version=2023-02-01-preview&features=objects&language=en&gender-neutral-caption=False" \ -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: VALID_KEY_USED" \ --data "{\"url\":\"https://images.openai.com/blob/9ad5a2ab-041f-475f-ad6a-b51899c50182/ingredients.png\"}"

Any log messages given by the failure

Analysis failed. Error reason: ImageAnalysisErrorReason.CONNECTION_FAILURE Error code: -1 Error message: Unknown error in sending http request

Expected/desired behavior

output should be json with the below result {"objectsResult":{"values":[{"boundingBox":{"x":167,"y":419,"w":301,"h":279},"tags":[{"name":"Egg","confidence":0.543}]},{"boundingBox":{"x":247,"y":669,"w":291,"h":285},"tags":[{"name":"Egg","confidence":0.617}]},{"boundingBox":{"x":445,"y":405,"w":559,"h":358},"tags":[{"name":"Food","confidence":0.711}]}]},"modelVersion":"2023-02-01-preview","metadata":{"width":1006,"height":1006}}

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

azure-ai-vision-0.13.0b1 python 3.10.10

Mention any other details that might be useful


Thanks! We'll be in touch soon.

mattmazzola commented 1 year ago

I can confirm I also receive this error. I hadn't been able to receive a single successful request using the 4.0 API.

The "unknown error" is not very helpful. I am also suspicious because I am using HTTPS but the error message says HTTP.

azure-ai-vision: 0.13.0b1 python: 3.10.6

dargilco commented 1 year ago

@lordlinus please run sample number 0 (image_analysis_sample_analyze) here: https://github.com/Azure-Samples/azure-ai-vision-sdk/tree/main/samples/python/image-analysis . Your link points to an example of using custom model. Seems like you did not intend to use a custom model.

dargilco commented 1 year ago

@mattmazzola please share more information on your case. Share source code. What OS/Platform is this? Does an equivalent CURL command work? What happens when you run sample number 0 here with your endpoint and computer vision key? https://github.com/Azure-Samples/azure-ai-vision-sdk/tree/main/samples/python/image-analysis

lordlinus commented 1 year ago

@dargilco i get the same error when i ran the sample

image

mattmazzola commented 1 year ago

please share more information on your case

I created a video to give some more context. I can't easily share the code without creating separate repo and moving my script and dependencies over to make it public.

https://github.com/Azure-Samples/azure-ai-vision-sdk/assets/2856501/34d7f777-b669-4598-8c68-e8ef8b34008f

this error message indicates that Open SSL 1.x was not installed

You may know that from internal knowledge of how the code works, but this error message does NOT imply that is the issue. It only says "Unknown error in sending http request"

It seems like a generic error for any issues that happen. It would be more helpful if you listed probable causes for that error in the error message such as:

"If you are using Ubuntu 22.04 required to download and install the latest libssl1.1 package (e.g. from http://security.ubuntu.com/ubuntu/pool/main/o/openssl/)"

I suspect I am having the same problem since I am running from within this container environment:

mcr.microsoft.com/devcontainers/base:ubuntu-22.04

dargilco commented 1 year ago

@mattmazzola @lordlinus I need to correct the relevant README documents in this repo with regards to running the Vision SDK on Ubuntu 22.04. Until the Vision SDK is updated to use OpenSSL 3.x, you must download and compile OpenSSL 1.x yourself. There is no existing Debian package for OpenSSL 1.x on Ubuntu 22.04, as version 1.x is about to end its life support. It's simple to compile OpenSSL 1.x. The instructions are the same as we have for the Microsoft Speech SDK here. The only difference is that for Vision SDK there is no need to install the libasound package. Please try this and let me know if that solved your problem. I expect Vision SDK to be updated to use OpenSSL 3.x in an upcoming release, so all this will not be needed. In the meanwhile, I will consider updating the error message as suggested. Thanks!

mattmazzola commented 1 year ago

let me know if that solved your problem

I was struggling with the manual installation steps and I ended up downgrading the container to use mcr.microsoft.com/devcontainers/base:ubuntu-20.04 and now I can use the Python SDK with v4.0 API and am unblocked! 😄Thank for the response about Open SSL.

dargilco commented 1 year ago

I added this document to the samples repo, and updated the relevant Linux README files to point to it. I also made an SDK code change such that the error message will mention that if you are running on Ubuntu 22.04 you need to install OpenSSL 1.x from source code, including a link to this new document. This change will be included in the next version of the SDK (we release every 1-2 months). We will also write a dedicated Vision SDK setup page under the public Image Analysis document addressing this.

@mattmazzola if the instructions to setup OpenSSL 1.x from source code did not work for you, please open a new GitHub issue with a description of what you’ve done and the issue you encountered.

@mattmazzola @lordlinus if you have any other issues or feedback in general on the SDK, feel free to open a new issue. I will close this one.

fengjihua commented 11 months ago

Error reason: ImageAnalysisErrorReason.CONNECTION_FAILURE Error code: -1 Error message: Unknown error in sending http request

OS and Version CentOS 7.9.2009 (works fine on local Windows 10)

Versions azure-ai-vision 0.13.0b1 python 3.8.12 (Gunicorn + Flask) OpenSSL 1.0.2k urlib 1.26

Azure-Cognitive-Speech and Azure-Cognitive-Language service are working fine on same server

dargilco commented 11 months ago

@fengjihua Unfortunately we do not support CentOS 7. I believe it should work on CentOS 8.