https://prefect.io logo
Title
d

Dung Khuc

06/09/2022, 6:01 PM
Hello, we are trying to run prefect agent behind a proxy and encounter this:
Error downloading Flow from Azure: ('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Following env vars are set
HTTPS_PROXY=x.x.x.x
AZURE_STORAGE_CONNECTION_STRING=xxxx
We can connect to blob should just fine using
az
. Any pointer?
1
k

Kevin Kho

06/09/2022, 7:04 PM
Hmm I don’t have a good suggestion, but I guess a quick test is to see if you can hit the Prefect API? For example:
import requests

query = """
{
  flow{ 
    id
    name
  }
}
"""
response = <http://requests.post|requests.post>(
    url="<https://api.prefect.io>",
    headers=dict(authorization=f"Bearer {API_KEY}"),
)
print(response.status_code)
print(response.text)
and maybe it will have more details in the traceback?
a

Anna Geller

06/09/2022, 7:13 PM
You may need to add it to trusted hosts?
d

Dung Khuc

06/09/2022, 7:21 PM
@Kevin Kho I'm not very familiar with graphql, should I pass
query
value to
data
param in
<http://requests.post|requests.post>
? I got 'POST body missing. Did you forget use body-parser middleware?'
@Anna Geller can you elaborate, what should I add to trusted hosts?
k

Kevin Kho

06/09/2022, 7:23 PM
whoops
response = <http://requests.post|requests.post>(
    url="<https://api.prefect.io>",
    json=dict(query=query),
    headers=dict(authorization=f"Bearer {API_KEY}"),
)
d

Dung Khuc

06/09/2022, 7:25 PM
status_code
is 200 and
response.text
returns list of flows
from the log I think the agent can connect to prefect, but it cannot fetch the flow from blob storage
9 June 2022,09:14:31 	agent	INFO	Submitted for execution: PID: 8472
9 June 2022,09:14:32 	prefect.Azure	INFO	Downloading azure-flow/2022-06-09t17-19-17-739489-00-00 from cdp-prefect-agent1
9 June 2022,09:15:57 	prefect.Azure	ERROR	Error downloading Flow from Azure: ('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
9 June 2022,09:15:58 	execute flow-run	ERROR	Failed to load and execute flow run: ServiceRequestError("('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))")
I looked into prefect's
Azure
storage source code and wrote a separate python script with similar code to download from blob, the script works fine
k

Kevin Kho

06/09/2022, 8:00 PM
I guess the question is if both the place you tested and the agent run with the same settings?
d

Dung Khuc

06/09/2022, 8:01 PM
yes, I tested that in the same VM that I run agent in
same env vars and everything
I figured this out. It's my mistake specifying the connection string env var when creating windows service. It doesn't like
"
enclosure.
k

Kevin Kho

06/09/2022, 8:30 PM
Ahh glad you got it figured out!
d

Dung Khuc

06/09/2022, 8:30 PM
Thanks a lot for helping! The last comment raise my suspicion to check how windows service env var works
🙌 1