1

I have set up a database and php file running on my host and I run a python code that uploads a json file every 5 minutes using the Requests module. After about 6-8 hours, the app crashes and produces this error:

Max retries exceeded with url: /rpitest2.php (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)

What could be the reason for this?

alandalusi
  • 1,145
  • 4
  • 18
  • 39
  • Doing some googleing, came across this: http://stackoverflow.com/questions/4673166/python-httplib-name-or-service-not-known :: looks like it has your exception and error mentioned among some of the answers and descriptions – pyInTheSky Feb 27 '13 at 19:19
  • I am guessing its a different issue, because in my case, the system works fine for hours, it only fails later. – alandalusi Feb 27 '13 at 19:35

1 Answers1

1

This could happen with badly formed URLs or a DNS failure.

Can you log the full URL that is being accessed? Seems like it is getting corrupted over time.

sureshvv
  • 4,234
  • 1
  • 26
  • 32
  • some part of the variable getting overwritten... try to catch the exception and print out the full url... assume you have the http:// in front – sureshvv Feb 27 '13 at 19:43
  • Can you explain more? what do you mean by overwritten? and how do propose that I write the exception? the URL is anas.basalamah.net/rpitest2.php unless you mean something else by url. – alandalusi Feb 27 '13 at 19:48
  • just guessing here... may be you are constructing the url and something breaks... use a try/except around the line you get this error and log the url.. if it is fine, then may be your DNS or ISP could be the problem – sureshvv Feb 27 '13 at 19:55
  • could it be because the time between two concecutive posts to the url? I was able to recreate the issue by reducing the time from of two consecutive posts from 5 minutes to 5 seconds. – alandalusi Feb 27 '13 at 20:00
  • don't think so.. you should get a different error (http code) for that – sureshvv Feb 27 '13 at 20:11
  • true, it seams that the problem is indeed with the 3g modem. It lost its connectivity with the network after running several hours. – alandalusi Feb 27 '13 at 20:47