Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket.timeout: The read operation timed out #8

Closed
ZuinigeRijder opened this issue Sep 18, 2022 · 1 comment
Closed

socket.timeout: The read operation timed out #8

ZuinigeRijder opened this issue Sep 18, 2022 · 1 comment
Assignees

Comments

@ZuinigeRijder
Copy link
Owner

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 ZuinigeRijder self-assigned this Sep 18, 2022
@ZuinigeRijder
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant