Author Topic: WeatherLink Live crashes  (Read 530 times)

0 Members and 1 Guest are viewing this topic.

Offline allenm

  • Member
  • *
  • Posts: 8
WeatherLink Live crashes
« on: January 17, 2022, 09:14:52 AM »
I have a Davis Vantage Vue with a WeatherLink Live (WLL). Besides uploading to weatherlink.com (Basic) every 60 seconds, I'm also uploading to Weather Underground and CWOP every 15 minutes. All of this works great. Kudos to the Davis development folks!

Never having enough data, I decided to also use the weatherlink live api (V1) to save the json data to a daily log file every 15 minutes. That's running on a Raspberry Pi using a modified version of the "Current Conditions HTTP Request Ė Helper Module [Python]" listed on the https://weatherlink.github.io/weatherlink-live-local-api/ page.

That runs and logs data ok but crashes at random times. Sometimes it runs a few hours, sometimes a whole day or more. I suspect it crashes when the API tries to access the WLL at the same exact time the WLL is uploading to one of the 3 cloud servers noted above.

It has nothing to do with the Raspberry Pi or its internet connection. The same thing happens running the same Python program on one of my Windows 10 laptop.

Here's my program:

import time
import socket
import os
import json
from multiprocessing import Process
import requests

current_conditions_url = 'http://10.0.0.42:80/v1/current_conditions'
myDate1 = time.strftime("%Y%m%d")
myDate2 = myDate1
def make_request_using_socket(url):
        try:
            resp = requests.get(url)
            print("HTTP Response Code:", resp)
            json_data = json.loads(resp.text)       
            if json_data["data"] == None:
               print (json_data["error"])
            else:
               global myDate2
               myDate1 = time.strftime("%Y%m%d")
               if myDate1 == myDate2:   
                  wxFile = open('wx' + myDate1 + '.txt', 'a')
                  print (json_data, file = wxFile)
                  wxFile.close()
               else:
                  myDate2 = myDate1
                  wxFile = open('wx' + myDate1 + '.txt', 'a')
                  print (json_data, file = wxFile)
                  wxFile.close()
           
        except ConnectionRefusedError:
            print("Encountered 'ConnectionRefusedError'. Please Retry")
        except TimeoutError:       
            print("Encountered 'TimeoutError'. Please Retry")

def main():
    while True:
        global current_conditions_url
        try:           
            make_request_using_socket(current_conditions_url)
            time.sleep(3)
        except ConnectionRefusedError:
            print("Encountered 'ConnectionRefusedError'. Please Retry")
        except TimeoutError:       
            print("Encountered 'TimeoutError'. Please Retry")         
        time.sleep(300)
       
if __name__ == "__main__":
    main()

Here's the error I randomly get:

HTTP Response Code: <Response [200]>
HTTP Response Code: <Response [200]>
HTTP Response Code: <Response [200]>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1336, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 275, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1336, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 275, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "HttpCurrentConditions2.py", line 48, in <module>
    main()
  File "HttpCurrentConditions2.py", line 39, in main
    make_request_using_socket(current_conditions_url)
  File "HttpCurrentConditions2.py", line 13, in make_request_using_socket
    resp = requests.get(url)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
pi@raspberrypi:~ $


Not being quite sure what error I should try to add an except for, I'm going to add a 3rd except to wait 3 seconds and try again. It's been running about 3 hours, but I'm not sure that will do the trick or not.

except ConnectionRefusedError:
      print("Encountered 'ConnectionRefusedError'. Please Retry")
except TimeoutError:       
      print("Encountered 'TimeoutError'. Please Retry")
except:
      time.sleep(3)

Any ideas would be appreciated?

Offline cmelby76

  • Member
  • *
  • Posts: 17
Re: WeatherLink Live crashes
« Reply #1 on: February 03, 2022, 12:28:33 PM »
My WeatherLink live crashes too. Could be hours or days later but then crashes.  I got a new WLL from Davis and same thing.  I am now thinking it my router. Has WiFi 6 and that might be my problem..  I have no clue. Iím going to call Davis again today

Good luck with yours. Itís a pain to keep resetting the thing

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 933
    • Wilmslow Astro
Re: WeatherLink Live crashes
« Reply #2 on: February 03, 2022, 12:47:33 PM »
@OP: You've got to expect any http query to fail at some time or other. Yes the WLL does sometimes close the connection without responding, but packets may get dropped by network etc. and your script should expect and handle those errors. You are doing the right thing by adding the exception handling, backing off a few seconds and trying again, in my experience that works virtually 100% of the time.

Btw, I'm pretty sure it's not the WLL that does the uploads to third parties, the cloud servers handle that. The WLL just uploads to the wl.com cloud once a minute.
Mark

Offline allenm

  • Member
  • *
  • Posts: 8
Re: WeatherLink Live crashes
« Reply #3 on: February 03, 2022, 12:49:23 PM »
I notice the subject I put on my post is very misleading. It was my Python program that was crashing not WeatherLink Live. WeatherLink Live was and is running fine for me. I think I have fixed my Python program by waiting 3 seconds if I don't get a 200 response and trying again. My program has been running fine now for almost 3 weeks.



 

anything