0

I am running a 6 script and they are running at different timings using systemd service and timer. Each script access the same url at least once. When I check the log file of some scripts, they are showing an error like following

ConnectionError(MaxRetryError("HTTPSConnectionPool(host='www.xxxxxxxx.com', port=443): Max retries exceeded with url: /sensorConfig (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x75d165b0>: Failed to establish a new connection: [Errno -2] Name or service not known',))",),)

I replaced the site name with xxxxxxxx since it is confidential. Actually, I was thinking it was due to the internet failure but it was not. Because I can access the site using the browser without problem and also I can ping to the same site without problem.

I am actually sending POST requests using the python3.6 package "requests.post".

I have searched the internet but no one gives a solution.

How can I solve this error?

7
  • does the site accept POST requests? Commented Mar 5, 2021 at 5:58
  • Yes the scripts don't have problem always. only sometimes
    – vishnu m c
    Commented Mar 5, 2021 at 6:09
  • well, you say I was thinking it was due to the internet failure but it was not. Because I can access the site using the browser ... but unless you try to access the site with a browser at EXACTLY the same time as when a script fails, how can you rule out internet failure? Commented Mar 5, 2021 at 6:58
  • One more thing, I was controlling the raspberry pi using anydesk remote access. Unless the internet is not available, I can't control it. when run the script manually, i got the error.
    – vishnu m c
    Commented Mar 5, 2021 at 9:45
  • Are you sure the remote site can handle the load - with the service not being available I feel its the host end more than the Pi? Any command accessing services outside the current Pi program should be built around a try / except block in Python w3schools.com/python/python_try_except.asp to stop your program dying.
    – user130616
    Commented Mar 5, 2021 at 14:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.