python3 request POST times out when calling Azure function app - python-3.x

I have a python program that reads a file and posts the data to an Azure function app. Over the past few weeks, I have started noticing this error in the logs. This program is about a year old and has never had an issue like this.
HTTPSConnectionPool(host=xxxx.azurewebsites.net', port=443): Max retries exceeded with url: /api/xxxx?code=zzzzzzzzzzz== (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ff96b5f0790>: Failed to establish a new connection: [Errno 110] Connection timed out'))
offending line from program:
response = requests.request("POST", xxxx.azurewebsites.net, json=post_data)
I do not get the error every time.
What could/would cause this issue and how do I correct it?

Related

Azure Custom Vision SDK - ClientRequestError

I am trying out an object detection project with the Custom Vision client library. But I get ClientRequestError. Below is my code:-
from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient
from azure.cognitiveservices.vision.customvision.training.models import ImageFileCreateEntry
from msrest.authentication import ApiKeyCredentials
cv_endpoint = "https://westeurope.api.cognitive.microsoft.com"
training_key = "*******************"
training_images = "LegoSimpsons/TrainingImages"
credentials = ApiKeyCredentials(in_headers={"Training-key": training_key})
trainer = CustomVisionTrainingClient(credentials=credentials,endpoint=cv_endpoint)
for domain in trainer.get_domains():
print(domain.id, "\t", domain.name)
I get the below error:
ClientRequestError: Error occurred in request., ProxyError:
HTTPSConnectionPool(host='southcentralus.api.cognitive.microsoft.com',
port=443): Max retries exceeded with url:
/customvision/v3.4-preview/training/domains (Caused by
ProxyError('Cannot connect to proxy.',
NewConnectionError('<urllib3.connection.HTTPSConnection object at
0x000001CA81115588>: Failed to establish a new connection: [WinError
10061] No connection could be made because the target machine actively
refused it')))
Seems there is something wrong with your cv_endpoint, If you have created a Custom Vision Training service in your subscription:
you can find the key and endpoint here:
This is my test result:

basic_auth not working anymore after moving from JIRA to JIRA DataCenter, SSLError 443 error

I was using JIRA API for Python up until now to connect to JIRA, like so:
from jira import JIRA
options = {'server': 'http://it.company.com/'}
jira = JIRA(options, basic_auth=('user', 'token'), max_retries=1)
However, since we moved from JIRA to JIRA DataCenter yesterday, this script doesn't work anymore. I get the following error message:
SSLError: HTTPSConnectionPool(host='it.company.com', port=443): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
Why is this occurring? What changed in the authentication from JIRA to Jira DataCenter?
Today it works again. I'm not sure what the cause of the error was.

Query Crate Database by SQLAlchemy Dialect: No more Servers available

I'd like to give it a try with crate. I first tried it by loading some twitter data and query from admin UI successfully. However, when I tried to make a query with SQLAlchemy, I've got the following error.
OperationalError: (crate.client.exceptions.ConnectionError)
No more Servers available, exception from last server: HTTPConnectionPool(host='localhost', port=4200):
Max retries exceeded with url:
/_sql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f51485b2c18>:
Failed to establish a new connection: [Errno 111] Connection refused'))
[SQL: SELECT * FROM tweets LIMIT 100; ]
(Background on this error at: http://sqlalche.me/e/e3q8)
This is the code I ran that caused the error.
from crate import client
import sqlalchemy as sa
import pandas as pd
engine = sa.create_engine('crate://localhost:4200')
query = (
"SELECT * "
"FROM tweets "
"LIMIT 100; "
)
df = pd.read_sql(query, engine)
Any idea how to fix it (the settings are all default)?
Update:
Crate is running on host system while Jupyter is running in a container on the same machine.
I can access Crate via "http://localhost:4200" on the host machine but can't do "http://xxx.xxx.xxx.xxx:4200" from other machine in the same natwork.
I tried both:
engine = sa.create_engine('crate://10.7.116.222:4200')
engine = sa.create_engine('crate://')
which caused the same error:
Removed server http://127.0.0.1:4200 from active pool
Removed server http://127.0.0.1:4200 from active pool
OperationalError: (crate.client.exceptions.ConnectionError)
No more Servers available, exception from last server:
HTTPConnectionPool(host='127.0.0.1', port=4200):
Max retries exceeded with url:
/_sql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5147faaa58>:
Failed to establish a new connection: [Errno 111] Connection refused'))
[SQL: SELECT * FROM tweets LIMIT 10; ]
(Background on this error at: http://sqlalche.me/e/e3q8)
I haven't tried it but according to the documentation 'localhost:4200' is assumed so you could connect using just engine = sa.create_engine('crate://')

Is any way to fix NewConnectionError occurred while calling a API?

I am trying to call an API which used to work fine previously, suddenly it started to throw newConnectionError. How can I get this fixed?
I tried to run the same API on my local machine and on the test environment, working fine there.
I expect a successful connection.
Error Message:
eport (Caused by NewConnectionError(': Failed to establ
ish a new connection: [Errno 110] Connection timed out',)).

Unable to connect h2o server python3

I have a problem trying to connect to the h2o server. The first time i'm able to do it. But the second time i get this error:
[18:56.78] H2OConnectionError: Unexpected HTTP error: HTTPConnectionPool(host='127.0.0.1', port=54321): Max retries exceeded with url: /3/Cloud (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3041303dd8>: Failed to establish a new connection: [Errno 111] Connection refused',))
At the begining of my script i have:
h2o.init(ip="127.0.0.1", port="54321")
I down know if the first time the connection didnt close. Any body can help me?
Thank you very much

Resources