Hello, we are trying to run prefect agent behind a...
# prefect-community
d
Hello, we are trying to run prefect agent behind a proxy and encounter this:
Copy code
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
Copy code
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
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:
Copy code
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
You may need to add it to trusted hosts?
d
@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
whoops
Copy code
response = <http://requests.post|requests.post>(
    url="<https://api.prefect.io>",
    json=dict(query=query),
    headers=dict(authorization=f"Bearer {API_KEY}"),
)
d
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
Copy code
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
I guess the question is if both the place you tested and the agent run with the same settings?
d
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
Ahh glad you got it figured out!
d
Thanks a lot for helping! The last comment raise my suspicion to check how windows service env var works
🙌 1