thijsbekke / OctoPrint-Pushover

A Pushover plugin for OctoPrint
GNU General Public License v3.0
33 stars 21 forks source link

Plugin interrupts startup.... #66

Open ThomasCr opened 3 years ago

ThomasCr commented 3 years ago

Hi, with the plugin installed from repository and configured the webinterfaces from octoprint dont comes up.

I activated plugin debug and found this:

Sep 21 21:24:11 octopi octoprint[6409]: 2021-09-21 21:24:11,685 - octoprint.plugins.pushover - DEBUG - Got an event: ClientClosed, payload: {'remoteAddress': '192.168.99.50'}
Sep 21 21:24:11 octopi octoprint[6409]: 2021-09-21 21:24:11,687 - octoprint.plugins.pushover - DEBUG - event: ClientClosed has an AttributeError {'remoteAddress': '192.168.99.50'}
Sep 21 21:28:35 octopi octoprint[6409]: 2021-09-21 21:28:35,408 - octoprint.plugins.pushover - DEBUG - Got an event: UserLoggedIn, payload: {'username': 'thomas'}
Sep 21 21:28:35 octopi octoprint[6409]: 2021-09-21 21:28:35,408 - octoprint.plugins.pushover - DEBUG - event: UserLoggedIn has an AttributeError {'username': 'thomas'}
Sep 21 21:28:42 octopi octoprint[6409]: 2021-09-21 21:28:42,889 - octoprint.plugins.pushover - DEBUG - Got an event: ClientClosed, payload: {'remoteAddress': '192.168.99.50'}
Sep 21 21:28:42 octopi octoprint[6409]: 2021-09-21 21:28:42,890 - octoprint.plugins.pushover - DEBUG - event: ClientClosed has an AttributeError {'remoteAddress': '192.168.99.50'}

this messages loops multiple times ...

Any idea what could me wrong?

ThomasCr commented 3 years ago

192.168.99.50 is the client ip who wants to access the webinterface.

When I kill octoprint for a restart, I get this:

Sep 21 21:34:39 octopi octoprint[6585]: 2021-09-21 21:34:39,489 - octoprint.startup - INFO - ******************************************************************************
Sep 21 21:34:39 octopi octoprint[6585]: 2021-09-21 21:34:39,491 - octoprint.startup - INFO - Starting OctoPrint 1.6.1
Sep 21 21:34:39 octopi octoprint[6585]: 2021-09-21 21:34:39,491 - octoprint.startup - INFO - Starting in SAFE MODE. Third party plugins will be disabled!
Sep 21 21:34:39 octopi octoprint[6585]: 2021-09-21 21:34:39,492 - octoprint.startup - INFO - Reason for safe mode: problem during last startup
Sep 21 21:34:39 octopi octoprint[6585]: 2021-09-21 21:34:39,492 - octoprint.startup - INFO - ******************************************************************************

And when I than disable the pushover plugin and restart the webinterfaces comes up normally.

ThomasCr commented 3 years ago

I think I know why this happend.... your code lacks a timeout definition on the web requests.

When you make an inline request to an external service, your system will need to wait upon the response before moving on. If your application waits too long for that response, requests to your service could back up, your user experience could suffer, or your background jobs could hang.

By default, requests will wait indefinitely on the response, so you should almost always specify a timeout duration to prevent these things from happening.

Source: https://realpython.com/python-requests/#timeouts

as seen on those code-lines:

https://github.com/thijsbekke/OctoPrint-Pushover/blob/1166559d5ee480e3b2b56d492c984838b4585408/octoprint_pushover/__init__.py#L112 https://github.com/thijsbekke/OctoPrint-Pushover/blob/1166559d5ee480e3b2b56d492c984838b4585408/octoprint_pushover/__init__.py#L494

my problem was a faulty ipv6 setup - but this should not end in a not starting octoprint ;-)

AlexVercammen commented 3 years ago

Could this lack of timeouts being the reason for the issue #63 "no Pushover message with event PrintStarted"?https://github.com/thijsbekke/OctoPrint-Pushover/issues/63

thijsbekke commented 3 years ago

I will look into this as soon as I find the time for it. And that is first thing next week. I think @ThomasCr is right here, a timeout definition is missing.

thijsbekke commented 3 years ago

This issue is fixed but I wait with the release when https://github.com/thijsbekke/OctoPrint-Pushover/issues/63 is also fixed.