I have this line for code where I am sending a get() request to a http server:
json_data = requests.get(
"http://"+ <host_ip> + <http_resource_path>,
auth=HttpNtlmAuth('<Username>', '<Passwrd>'), headers={'host': host_DNS_name}).json()
Now when I execute this code it succeeds but I notice it's taking 3 attempts to succeed(the code hits the url 3 times and succeeds in the 3rd attempt with frist 2 resulting in 401 error). This is what I see on my console when I execute this code:
http://<host-IP:80 "GET <http_resource_path> HTTP/1.1" 401 58
http://<host-IP:80 "GET <http_resource_path> HTTP/1.1" 401 341
http://<host-IP:80 "GET <http_resource_path> HTTP/1.1" 200 74
As you can see with same URL, credentials and port number(it's 80) every time, it's taking 3 attempts to succeed(first 2 attempts are resulting in unauthorized access but the 3rd one succeeds with the same parameters). This multiple attemptis causing a latency of about 15 seconds(between 1st and 3rd attempt). Now I am unable to understand why is taking 3 attempts to succeed when the parameters are not changed? Is there something in my code that I can do to resolve this issue and/or debug or is the issue in the server I am trying to access?