Name resolution error

i have been uploading data for ~20 hours and my python script crashed/stopped due to a dns name resoluton error

does that happen a lot and could i bot use the ip number instead? or does the ip change to often?

Its probably best to keep logging to the domain name, we may change the ip address in the future. Can you catch the case where you have a dns resolution error?

nope the script just crashed and i forgot to take a screenshot,

but from what i remember it was DNS related, so it could be any dns server between me and you (and that is no small number :smiley: )

but should it happen again over the next few days i will post a screenshot

it could also be a fault in my python script

https://github.com/boelle/Rpi-Heating-Control/blob/master/heatcontrol.py

bit i have looked it over many times and i cant find anything wrong

maybe something that prevents the script from executing even if it cant reach emoncms

Wrap the http request line in a try/except so that it cannot crash your script if it fails for any reason. You could then go the extra mile and change the code to retry (after a short wait) creating a smaller loop within the outer loop. You will have to change the way it sleeps for 60sec though because if it takes a few attempts to succeeed in sending, that 60s sleep becomes a “minimum time between sends” not a regular interval.

oh the 60 sec was just a nice round number i picked

so i should do just like the ping to google dns servers? that also fails and crashes the script from time to time

and i have not found out why etc… i’m tempted to just use a bash script to check if the script is not running and if not start it… along the lines of this page: bash - How to restart the Python script automatically if it is killed or dies - Unix & Linux Stack Exchange

its the answer just below the one with green mark (the one with 11 votes)

Traceback (most recent call last):

  File "test.py", line 175, in <module>
    emoncms()
  File "test.py", line 134, in emoncms
    conn.request("GET", "/"+emoncmspath+"/input/post.json?apikey="+apikey+"&node="+str(nodeid)+"&csv="+str_join)
  File "/usr/lib/python2.7/httplib.py", line 1042, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1082, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 882, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 844, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 821, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.timeout: timed out