socket.timeout: The read operation timed out
ZuinigeRijder opened this issue · 1 comments
ZuinigeRijder commented
My python script stopped working yesterday after running for a few months without a problem:
socket.timeout: The read operation timed out
Apparently not all exceptions are catched in the urlopen call.
Stacktrace:
Traceback (most recent call last):
File "/home/rick/solis/soliscloud_to_pvoutput.py", line 210, in <module>
main_loop()
File "/home/rick/solis/soliscloud_to_pvoutput.py", line 154, in main_loop
content = get_solis_cloud_data(INVERTER_DETAIL, inverter_detail_body)
File "/home/rick/solis/soliscloud_to_pvoutput.py", line 95, in get_solis_cloud_data
content = execute_request(SOLISCLOUD_API_URL+url_part, data, headers)
File "/home/rick/solis/soliscloud_to_pvoutput.py", line 53, in execute_request
with urlopen(request, timeout=10) as response:
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 517, in open
response = self._open(req, data)
File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 1389, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/usr/lib/python3.9/urllib/request.py", line 1350, in do_open
r = h.getresponse()
File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.9/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
So exception socket.timeout should be catched. Also any other exception should be catched, for the retry mechanism.
Probably it would be good to increase the timeout from 10 to 30 (seconds).
ZuinigeRijder commented
Fixed in release R1.5.0: https://github.com/ZuinigeRijder/SolisCloud2PVOutput/tree/R1.5.0