Closed rickyzhang82 closed 4 years ago
@rickyzhang82 I just pushed a major update that allows you to have multiple webhooks. Should also fix this issue as I just tested your case. Let me know if it is still happening to you or if the problem is fixed.
I upgraded to Webhook 3.0.0 last night. I don't see it actually trigger my printer to turn off when the print is done.
How can I debug it or enable logging for Webhook? I don't see it output anything in the Octoprint print log file.
thanks!
@rickyzhang82 So it should look something like this photo. Under Testing -> you'll pick the event -> Print Done and then hit the "Simulate Webhook" button. Then, you should see a popup in the top right saying the web hook succeeded or failed like in the second picture. If there is an error sending the webhook, the message should tell you what the problem is. I need to update the readme to explain this better.
The problem is still there. Please register only one event such as "Done" in the webhook. Then, pick “Print Done” in test simulation. It doesn't work in the test simulation. It didn't invoke the hook. I did not see a green window or a red window pops up.
@rickyzhang82 I tried simulating your conditions and couldn't. It works fine for me. The only time I haven't received a red/green window was when the server took too long to respond. The green/red window will only popup once the server has responded or if there was an error. If I understand your API, you are delaying 30+ seconds before returning a response to the client. The green/red window will only popup when the server has responded (30+ seconds later).
My web hook server runs the at command, e.g. at + [x] hours /bin/command
directly and return the response immediately. I tested it fine from a web browser.
Can you output something in the Octoprint log file beside pops up a green/red window?
@rickyzhang82 Can you screenshot and upload what every parameter looks like for your webhook? Then, I'll download your plugin and test it out.
Sure. My web hook server is in 192.168.2.30. Clone my repo. make; sudo make install
should deploy it as systemd service. You can find the server log by journalctl
even you don't have my sonoff turn off command. It should show web hook get trigger but fail to execute when you test the URL below on web browser.
Any update? I found that if I select all events for web hook, the simulation test and real test passed. But it failed in both tests if I select just one event -- Done.
@rickyzhang82 So, I tested out your plugin. Couldn't get it to install under systemd (on a Mac), but ran it anyways locally. I had to change the command though as I didn't have permission to /usr/bin/at. Worked fine for me. The only thing I noticed is you have blank data in the HEADERS and DATA field. Should be {} instead of blank to be proper JSON. The plugin should warn you of this though with a red popup when you try to test it out (maybe red popups in general don't show up for you)? Also, I added in a 30 second timeout for web requests, so if it is a timeout issue you'll see a red notification popup after 30 seconds. Also, there are a bunch of INFO logs that are generated when the API request is being created/sent so you should be able to see what is happening. I couldn't reproduce your issue of selecting all events vs. one event so I'm not sure what to tell you about that. Do you have this issue if you try to send a request to https://www.google.com or some site we are sure works? If it works with Google and not your service, then it's probably an issue with your service. If it doesn't work with Google, then it could be an issue with my service. Also a quick note on your service. For me at least, and maybe this is because I couldn't install it as systemd, once the API is called once, the service shuts down and has to be run again. Test out this upgrade and see if it works for you and let me know what you figure out!
I downloaded 3.0.1
version. But the problem is still there. I only subscribed Print Done
event and kept the JSON structure intact in advance section. I don't see the webhook triggers Done event
in the log file after the print was done.
I did see a log message when I stopped the 3D printer. But this is wrong. Because I only subscribed the done event.
2020-05-23 20:53:44,164 - octoprint.plugins.webhooks - INFO - Hello World from WebhooksPlugin!
2020-05-23 20:58:20,791 - octoprint.plugins.webhooks - INFO - hook: {'oauth_content_type': 'JSON', 'event_print_progress': False, 'oauth_data': '{\n "client_id":"myClient",\n "client_secret":"mySecret",\n "grant_type":"client_credentials"\n}', 'oauth_http_method': 'POST', 'http_method': 'POST', 'eventUserActionNeededMessage': 'User action needed. You might need to change the filament color.', 'eventUserActionNeeded': False, 'deviceIdentifier': '', 'eventPrintProgressMessage': 'Your print is @percentCompleteMilestone % complete.', 'eventPrintPaused': False, 'eventPrintFailedMessage': 'Something went wrong and your print has failed.', 'eventErrorMessage': 'There was an error.', 'eventPrintStartedMessage': 'Your print has started', 'webhook_enabled': True, 'test_event': 'PrintStarted', 'eventPrintStarted': False, 'event_print_progress_interval': '50', 'apiSecret': '', 'oauth_headers': '{\n "Content-Type": "application/json"\n}', 'content_type': 'JSON', 'oauth': False, 'data': '{\n "deviceIdentifier":"@deviceIdentifier",\n "apiSecret":"@apiSecret",\n "topic":"@topic",\n "message":"@message",\n "extra":"@extra",\n "state": "@state",\n "job": "@job",\n "progress": "@progress",\n "currentZ": "@currentZ",\n "offsets": "@offsets",\n "meta": "@meta",\n "currentTime": "@currentTime",\n "snapshot": "@snapshot"\n}', 'eventPrintFailed': False, 'eventPrintPausedMessage': 'Your print has paused. You might need to change the filament color.', 'eventError': False, 'eventPrintDone': True, 'url': 'http://192.168.2.30:12000/done?delay=30', 'headers': '{\n "Content-Type": "application/json"\n}', 'eventPrintDoneMessage': 'Your print is done.', 'oauth_url': ''}
2020-05-23 20:58:20,839 - octoprint.plugins.webhooks - INFO - hook: {'oauth_content_type': 'JSON', 'event_print_progress': False, 'oauth_data': '{\n "client_id":"myClient",\n "client_secret":"mySecret",\n "grant_type":"client_credentials"\n}', 'oauth_http_method': 'POST', 'http_method': 'POST', 'eventUserActionNeededMessage': 'User action needed. You might need to change the filament color.', 'eventUserActionNeeded': False, 'deviceIdentifier': '', 'eventPrintProgressMessage': 'Your print is @percentCompleteMilestone % complete.', 'eventPrintPaused': False, 'eventPrintFailedMessage': 'Something went wrong and your print has failed.', 'eventErrorMessage': 'There was an error.', 'eventPrintStartedMessage': 'Your print has started', 'webhook_enabled': True, 'test_event': 'PrintStarted', 'eventPrintStarted': False, 'event_print_progress_interval': '50', 'apiSecret': '', 'oauth_headers': '{\n "Content-Type": "application/json"\n}', 'content_type': 'JSON', 'oauth': False, 'data': '{\n "deviceIdentifier":"@deviceIdentifier",\n "apiSecret":"@apiSecret",\n "topic":"@topic",\n "message":"@message",\n "extra":"@extra",\n "state": "@state",\n "job": "@job",\n "progress": "@progress",\n "currentZ": "@currentZ",\n "offsets": "@offsets",\n "meta": "@meta",\n "currentTime": "@currentTime",\n "snapshot": "@snapshot"\n}', 'eventPrintFailed': False, 'eventPrintPausedMessage': 'Your print has paused. You might need to change the filament color.', 'eventError': False, 'eventPrintDone': True, 'url': 'http://192.168.2.30:12000/done?delay=30', 'headers': '{\n "Content-Type": "application/json"\n}', 'eventPrintDoneMessage': 'Your print is done.', 'oauth_url': ''}
When the print was done, your plugin didn't trigger my webhook. I verified it form the Octoprint log file and my app server log in systemd.
I'm not sure if you expect any event will trigger my webhook even I explicitly ask for the trigger is for done event only. In any case, it still doesn't work in my use case.
Regarding to my Go app, you don't have to run it as a systemd service. You can run it in Mac from the backround like ./app&
. That's it.
Hey @rickyzhang82 just pushed out an update 3.0.2 that fixed a separate issue #9 . Not sure if it's related to your issue, but it might be worth giving it a try and seeing if it's fixed.
Also, if it doesn't work, can you try the following:
{}
Thanks for writing this plugin.
I wrote a web hook server to trigger a web hook to turn off 3D printer with a delay when the print is done.
But your simulation test fail when I only select one event. But if I select all events, the test passed.
Here is my test scenario: