dswd / OctoPrint-PSUControl-Tapo

Adds TPLink Smart Plug support to OctoPrint-PSUControl as a sub-plugin
GNU Affero General Public License v3.0
7 stars 1 forks source link

Slowdown and stops of the printer when the tapo isn't connected #7

Open Nisgrak opened 1 year ago

Nisgrak commented 1 year ago

Hi!

I run into a multiple issues with my printer and the last one is this plugin.

If the tapo plug isn't connected to the electricity (so the printer isn't connected to it, obviously) the printer slowdown and stops in the curves like this video https://www.reddit.com/r/FixMyPrint/comments/ul2urx/ender3v2_printing_very_slow_around_curves_klipper/i7wps43/?context=3

As seen in the log looks like it can't connect with the tapo and the http of request_raw fails, but maybe can improve the error so doesn't kill the printer

2023-01-10 23:23:24,080 - octoprint.plugins.psucontrol - ERROR - Error while executing callback <bound method PSUControl_Tapo.get_psu_state of <octoprint_psucontrol_tapo.PSUControl_Tapo object at 0xb274c718>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 179, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0xafa0d0b8>, 'Connection to 192.168.1.179 timed out. (connect timeout=0.5)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.179', port=80): Max retries exceeded with url: /app (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xafa0d0b8>, 'Connection to 192.168.1.179 timed out. (connect timeout=0.5)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol/__init__.py", line 292, in _check_psu_state
    r = callback()
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/__init__.py", line 90, in get_psu_state
    return self.device.get_status()
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/tapo.py", line 176, in get_status
    return self._get_device_info()["device_on"]
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/tapo.py", line 162, in _get_device_info
    return self._request("get_device_info")
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/tapo.py", line 72, in _request
    self._initialize()
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/tapo.py", line 138, in _initialize
    result = self._request_raw("handshake", {
  File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_psucontrol_tapo/tapo.py", line 55, in _request_raw
    resp = self.session.post(url, json=payload, timeout=0.5)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 553, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.1.179', port=80): Max retries exceeded with url: /app (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xafa0d0b8>, 'Connection to 192.168.1.179 timed out. (connect timeout=0.5)'))