OctoPrint-TPLinkSmartplug icon indicating copy to clipboard operation
OctoPrint-TPLinkSmartplug copied to clipboard

[BUG]: Delayed Load Times of OctoPrint if Plug Unreachable/Offline

Open jneilliii opened this issue 2 years ago • 0 comments

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:

  1. Go to the plugin's settings and enter an invalid IP address.
  2. Save the settings.
  3. 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)

jneilliii avatar May 17 '22 15:05 jneilliii