OctoPrint-TPLinkSmartplug
OctoPrint-TPLinkSmartplug copied to clipboard
[BUG]: Delayed Load Times of OctoPrint if Plug Unreachable/Offline
Describe the bug If a smartplug is registered with an IP and that IP is not online the OctoPrint UI takes a long time to load.
To Reproduce Steps to reproduce the behavior:
- Go to the plugin's settings and enter an invalid IP address.
- Save the settings.
- Refresh the page and notice that the file list doesn't propagate for a while.
Expected behavior The web interface to act normally.
Screenshots N/A
Additional context
I believe this may be related to socket timeout not being set and the default value being very long. Not sure if this delay is happening in socket.inet_aton(plugip)
or socket.gethostbyname(plugip)
or after.
Potential solution:
sock_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock_tcp.settimeout(5)
sock_tcp.connect((ip, 9999))
sock_tcp.settimeout(None)