For some reason, when I try making requests to Azu...
# ask-community
g
For some reason, when I try making requests to Azure OpenAI instances from my prefect flows, I get hostname cannot be resolved connection errors. I believe it could be related to SSL verification. I don't have this problem when running locally, only on my EKS. Has anyone here encountered similar problems? I found this github issue [0] which could be related and this prefect one [1] [0] https://github.com/openai/openai-python/issues/278 [1] https://discourse.prefect.io/t/how-to-disable-the-ssl-verification-when-setting-up-a-pr[…]e-verify-failed-unable-to-get-local-issuer-certificate/597
I'm able to hit the endpoint when ssh'ing into my worker and running
Copy code
nmap -p 443 <domain_name>.<http://openai.azure.com|openai.azure.com>
I am running my prefect deployments using prefect cloud and the
flow.serve
methods. Here's the output I'm seeing repeatedly:
Copy code
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='<domain_name>.<http://openai.azure.com|openai.azure.com>', port=443): Max retries exceeded with url: //openai/deployments/<deployment_name>/chat/completions?api-version=2023-07-01-preview (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f9f19b2b370>: Failed to resolve '<domain_name>.<http://openai.azure.com|openai.azure.com>' ([Errno -2] Name or service not known)"))
I ran the following script directly in my prefect flow
Copy code
@flow()
def my_flow():

 def is_port_open(url, port):
    try:
        ip = socket.gethostbyname(url)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(1)
        s.connect((ip, port))
        s.close()
        return True
    except Exception as e:
        print(e)
        return False

  assert is_port_open("<domain_name>.<http://openai.azure.com|openai.azure.com>", 443)
This failed with
Copy code
Flow run '<flow_run_name>' - [Errno -5] No address associated with hostname
On the other hand, if I run this code directly from my python shell on the same machine, it works. Anyone able to help resolve?
k
you mentioned worker and
.serve
, in this case do you mean the pod you're serving your flows from?
g
Hey @Kevin Grismore, this is correct. Though I after some back and forth with our cloud provider, I learned this is a result of how Azure returns DNS responses. Here's a relevant link [0]. I updated our EKS configuration and am now able to resolve the hostname properly. Here's a brief description of the issue which I received from our cloud provider engineers: "Azure OpenAI endpoints return longer-than-usual DNS responses, which forces clients to switch to EDNS, which sends and receives DNS responses over TCP instead of the usual UDP. This was available for web apps by default; I've made this the default setting for worker apps too. Updating your workers/pushing new deployments will automatically deploy the fix" [0] https://moonape1226.medium.com/domain-resolve-error-name-or-service-not-known-forazure-openai-service-domain-c32607357e57
^ Could be helpful in general for folks that are dealing with issues connecting to Azure openai instances 🙂
💙 1