bchanudet / OctoPrint-Octorant

Discord plugin for OctoPrint
MIT License
26 stars 14 forks source link

If the camera stream is not setup right, it wont send a message at all. #19

Closed cameroncros closed 6 years ago

cameroncros commented 6 years ago

I have got octorant setup without a webcam setup properly. When it octorant tries to send a message (with "Include Snapshot" on), the URL for the snapshot times out, and the message is not sent. It ideally should still send the message, perhaps with a warning that the camera is not setup right?

bchanudet commented 6 years ago

Hello and thanks for your feedback.

This looks somewhat close to what an other user found out in #15 and that should have been fixed with the commit 5d55b040e2b7187d57d8360c206def3235a28b1a.

But as you indicate that the URL times out, should I understand that you actually got a URL in the webcam setup, but this URL is not working properly? Or that the webcam URL were not setup at all?

In any case, would you mind sending me a log of your OctoPrint instance? The easiest way to get it is grab the file octoprint.log in the Logs section of the configuration page of OctoPrint. You can either attach it to this issue, or if you prefer send it to my e-mail address hello@benjaminchanudet.com.

Hopefully this will help me finding out the cause. In the meantime I will have a look at how a faulty URL is handled in Octoprint's timelapse feature.

cameroncros commented 6 years ago

My camera was not configured properly, so the URL was a dead URL (mjpg_streamer was not running on the port). Octorant then tried to get a snapshot, which timed out, and that caused the entire message to be aborted. I will get you a stack trace shortly.

cameroncros commented 6 years ago

Stack Trace:

Traceback (most recent call last): File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.6-py2.7.egg/octoprint/plugin/init.py", line 225, in call_plugin result = getattr(plugin, method)(*args, kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_octorant/init.py", line 183, in on_event return self.notify_event("printer_state_operational") File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_octorant/init.py", line 243, in notify_event return self.send_message(eventID, tmpConfig["message"].format(data), tmpConfig["with_snapshot"]) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_octorant/init.py", line 287, in send_message snapshotCall = requests.get(snapshotUrl) File "/home/pi/oprint/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/api.py", line 72, in get return request('get', url, params=params, kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/api.py", line 58, in request return session.request(method=method, url=url, kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/sessions.py", line 508, in request resp = self.send(prep, send_kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/sessions.py", line 618, in send r = adapter.send(request, kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/adapters.py", line 508, in send raise ConnectionError(e, request=request) ConnectionError: HTTPConnectionPool(host='192.168.1.117', port=8080): Max retries exceeded with url: /?action=snapshot (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x6f90ce30>: Failed to establish a new connection: [Errno 111] Connection refused',))

cameroncros commented 6 years ago

See: https://github.com/cameroncros/OctoPrint-DiscordRemote/commit/00464942fc16e32a1f2e3bbe99ae3caca0e8796a Cherry pick may not work, but something like that might work for you?