blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.71k stars 304 forks source link

Slack Notification Failing from Webhook #201

Closed m1lkman closed 4 years ago

m1lkman commented 4 years ago

Anyone else seeing this? I'm running in docker. Regular Slack notifications work but webhooks fail with the below errors in the log.

2019-12-02 21:13:45 - DEBUG   :: Thread-1 : Tautulli Notifiers :: Executing script in a new thread.
2019-12-02 21:13:45 - INFO    :: CP Server Thread-12 : Tautulli Config :: Writing configuration to file
2019-12-02 21:13:45 - INFO    :: CP Server Thread-12 : Tautulli Pmsconnect :: Terminating session 157 (session_id ee023913e07cffdc222802901f5b102d).
2019-12-02 21:13:45 - INFO    :: CP Server Thread-12 : Tautulli NotificationHandler :: Preparing notification for notifier_id 4.
2019-12-02 21:13:45 - ERROR   :: CP Server Thread-12 : Tautulli Notifiers :: Invalid Webhook json header data: No JSON object could be decoded
2019-12-02 21:13:45 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Subprocess returned with status code 0.
2019-12-02 21:13:45 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Script returned: 
  Tautulli API cmd 'notify' failed: Notification failed.
2019-12-02 21:13:45 - INFO    :: Thread-15 : Tautulli Notifiers :: Script notification sent.
blacktwin commented 4 years ago

Fails using what? Can you provide your entire log? I assume your using the kill_stream.py. If so, add the--debug argument to provide more detail as to what the script is doing and the information that is trying to be sent.

m1lkman commented 4 years ago

Yes, this is a webhook being called by kill_stream.py. Here's a more complete log. (note: I sanitized a few things for privacy)

2019-12-03 10:54:33 - INFO    :: MainThread : Tautulli WebStart :: Starting Tautulli web server on http://0.0.0.0:8181/
2019-12-03 11:30:43 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 8 started by user 2281320 (John Smith) with ratingKey 117578 (The Dragon Prince - Episode 1).
2019-12-03 11:30:47 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 8 paused.
2019-12-03 11:30:47 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 8 has changed transcode decision.
2019-12-03 11:30:47 - INFO    :: Thread-2 : Tautulli NotificationHandler :: Preparing notification for notifier_id 3.
2019-12-03 11:30:47 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Trying to run notify script, action: pause, arguments: [u'--jbop', u'paused', u'--sessionId', u'jk7qlaskx7a9eifujqkxgdzh', u'--killMessage', u'Your stream was paused for over 20 minutes and has been automatically stopped for you.', u'--notify', u'4', u'--richMessage', u'slack', u'--serverName', u'Cloud', u'--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F117578', u'--posterUrl', '', u'--richColor', u'#E5A00D', u'--debug']
2019-12-03 11:30:47 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Full script is: ['python', u'/scripts/tautulli/killstream/kill_stream.py', '--jbop', 'paused', '--sessionId', 'jk7qlaskx7a9eifujqkxgdzh', '--killMessage', 'Your stream was paused for over 20 minutes and has been automatically stopped for you.', '--notify', '4', '--richMessage', 'slack', '--serverName', 'Cloud', '--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F117578', '--posterUrl', '', '--richColor', '#E5A00D', '--debug']
2019-12-03 11:30:47 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Executing script in a new thread.
2019-12-03 11:50:56 - INFO    :: CP Server Thread-14 : Tautulli Config :: Writing configuration to file
2019-12-03 11:50:56 - INFO    :: CP Server Thread-14 : Tautulli Pmsconnect :: Terminating session 8 (session_id jk7qlaskx7a9eifujqkxgdzh).
2019-12-03 11:50:56 - INFO    :: CP Server Thread-14 : Tautulli NotificationHandler :: Preparing notification for notifier_id 4.
2019-12-03 11:50:56 - ERROR   :: CP Server Thread-14 : Tautulli Notifiers :: Invalid Webhook json header data: No JSON object could be decoded
2019-12-03 11:50:56 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Subprocess returned with status code 0.
2019-12-03 11:50:56 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Script returned: 
  Tautulli URL - http://localhost:8181
  Tautulli Public URL - https://tautulli.*******.com/
  Verify SSL - False
  Tautulli API key - xxxxxxxxxxxxxxxxxxxxxxxxxxxx53fd
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'terminate_session'
  Session 'jk7qlaskx7a9eifujqkxgdzh' from user 'John Smith' has been killed.
  Tautulli API cmd 'notify' failed: Notification failed.
2019-12-03 11:50:56 - INFO    :: Thread-15 : Tautulli Notifiers :: Script notification sent.
2019-12-03 11:51:04 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 8 has changed transcode decision.
2019-12-03 11:51:06 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 8 stopped.
2019-12-03 11:51:06 - DEBUG   :: Thread-3 : Tautulli ActivityProcessor :: Play duration for session 8 ratingKey 117578 is 2 secs which is less than 120 seconds, so we're not logging it.
2019-12-03 11:51:06 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Removing sessionKey 8 ratingKey 117578 from session queue
blacktwin commented 4 years ago

What does your notifier 4 look like? Did this just start happening or is this the first time you've ran this script or configuration of script? This is where your entire log would have been helpful.

m1lkman commented 4 years ago

It was working some time ago but I just realized this weekend it wasn't. Here's notifier 4. All other tabs are blank/default.

Screen Shot 2019-12-04 at 10 08 24 AM

Here is a complete log from startup to shutdown with a notify failure. Let me know what else you need.

2019-12-04 11:05:52 - INFO    :: MainThread : Starting Tautulli v2.1.38
2019-12-04 11:05:52 - INFO    :: MainThread : [Docker] Linux 5.0.0-36-generic (#39~18.04.1-Ubuntu SMP Tue Nov 12 11:09:50 UTC 2019)
2019-12-04 11:05:52 - INFO    :: MainThread : America/Los_Angeles (UTC-0800)
2019-12-04 11:05:52 - INFO    :: MainThread : Python 2.7.16 (default, May  6 2019, 19:28:45) 
[GCC 8.3.0]
2019-12-04 11:05:52 - INFO    :: MainThread : Program Dir: /app/tautulli
2019-12-04 11:05:52 - INFO    :: MainThread : Config File: /config/config.ini
2019-12-04 11:05:52 - INFO    :: MainThread : Database File: /config/tautulli.db
2019-12-04 11:05:52 - INFO    :: MainThread : Checking if the database upgrades are required...
2019-12-04 11:05:52 - INFO    :: MainThread : Checking if configuration upgrades are required...
2019-12-04 11:05:52 - DEBUG   :: MainThread : Trying to execute: "git rev-parse HEAD" with shell in /app/tautulli
2019-12-04 11:05:52 - DEBUG   :: MainThread : Git output: a637b3bb2419e5f5b32f9fcfb8dae86860d1f0d9
2019-12-04 11:05:52 - DEBUG   :: MainThread : Trying to execute: "git rev-parse --abbrev-ref --symbolic-full-name @{u}" with shell in /app/tautulli
2019-12-04 11:05:52 - DEBUG   :: MainThread : Git output: origin/master
2019-12-04 11:05:52 - INFO    :: MainThread : Retrieving latest version information from GitHub
2019-12-04 11:05:52 - DEBUG   :: MainThread : Requesting URL via GET method: https://api.github.com/repos/Tautulli/Tautulli/commits/master
2019-12-04 11:05:53 - DEBUG   :: MainThread : Latest version is a637b3bb2419e5f5b32f9fcfb8dae86860d1f0d9
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli is up to date
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli PlexTV :: Requesting resources for server...
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli Config :: Writing configuration to file
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli PlexTV :: Using user-defined URL.
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli Config :: Writing configuration to file
2019-12-04 11:05:53 - INFO    :: MainThread : Tautulli Users :: Requesting users list refresh...
2019-12-04 11:05:55 - INFO    :: MainThread : Tautulli Users :: Users list refreshed.
2019-12-04 11:05:55 - INFO    :: MainThread : Tautulli Libraries :: Requesting libraries list refresh...
2019-12-04 11:05:57 - INFO    :: MainThread : Tautulli Config :: Writing configuration to file
2019-12-04 11:05:57 - INFO    :: MainThread : Tautulli Libraries :: Libraries list refreshed.
2019-12-04 11:05:57 - INFO    :: MainThread : Tautulli NotificationHandler :: Starting background notification handler (2 threads).
2019-12-04 11:05:57 - DEBUG   :: MainThread : Tautulli Monitor :: Checking for active streams.
2019-12-04 11:05:57 - INFO    :: Thread-3 : Tautulli WebSocket :: Opening websocket.
2019-12-04 11:05:57 - INFO    :: Thread-3 : Tautulli WebSocket :: Ready
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Check GitHub for updates
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Backup Tautulli database
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Backup Tautulli config
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Refresh Plex server URLs
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Check for Plex updates
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Refresh users list
2019-12-04 11:05:57 - INFO    :: Thread-3 : Scheduled background task: Refresh libraries list
2019-12-04 11:05:57 - INFO    :: MainThread : Tautulli WebStart :: Starting Tautulli web server on http://0.0.0.0:8181/
2019-12-04 11:06:23 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 47 started by user 2281320 (John Smith) with ratingKey 117578 (The Dragon Prince - Episode 1).
2019-12-04 11:06:24 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 47 stopped.
2019-12-04 11:06:24 - DEBUG   :: Thread-3 : Tautulli ActivityProcessor :: Play duration for session 47 ratingKey 117578 is 1 secs which is less than 120 seconds, so we're not logging it.
2019-12-04 11:06:24 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Removing sessionKey 47 ratingKey 117578 from session queue
2019-12-04 11:06:38 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 48 started by user 2281320 (John Smith) with ratingKey 117578 (The Dragon Prince - Episode 1).
2019-12-04 11:06:53 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 49 started by user 2281320 (John Smith) with ratingKey 45690 (Voltron: Legendary Defender - Omega Shield).
2019-12-04 11:06:53 - INFO    :: Thread-1 : Tautulli NotificationHandler :: Preparing notification for notifier_id 6.
2019-12-04 11:06:54 - DEBUG   :: Thread-1 : Tautulli Notifiers :: Trying to run notify script, action: concurrent, arguments: [u'--jbop', u'stream', u'--username', u'John Smith', u'--sessionId', u'ydi624p9r8f6s5il6kgmphyg', u'--killMessage', u'You are only allowed to stream from one location at a time.', u'--notify', u'4', u'--richMessage', u'slack', u'--serverName', u'Cloud', u'--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F45690', u'--posterUrl', '', u'--richColor', u'#E5A00D', u'--debug']
2019-12-04 11:06:54 - DEBUG   :: Thread-1 : Tautulli Notifiers :: Full script is: ['python', u'/scripts/tautulli/killstream/kill_stream.py', '--jbop', 'stream', '--username', 'John Smith', '--sessionId', 'ydi624p9r8f6s5il6kgmphyg', '--killMessage', 'You are only allowed to stream from one location at a time.', '--notify', '4', '--richMessage', 'slack', '--serverName', 'Cloud', '--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F45690', '--posterUrl', '', '--richColor', '#E5A00D', '--debug']
2019-12-04 11:06:54 - DEBUG   :: Thread-1 : Tautulli Notifiers :: Executing script in a new thread.
2019-12-04 11:06:54 - INFO    :: CP Server Thread-12 : Tautulli Config :: Writing configuration to file
2019-12-04 11:06:54 - INFO    :: CP Server Thread-12 : Tautulli Pmsconnect :: Terminating session 49 (session_id ydi624p9r8f6s5il6kgmphyg).
2019-12-04 11:06:54 - INFO    :: CP Server Thread-12 : Tautulli NotificationHandler :: Preparing notification for notifier_id 4.
2019-12-04 11:06:54 - ERROR   :: CP Server Thread-12 : Tautulli Notifiers :: Invalid Webhook json header data: No JSON object could be decoded
2019-12-04 11:06:54 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Subprocess returned with status code 0.
2019-12-04 11:06:54 - DEBUG   :: Thread-15 : Tautulli Notifiers :: Script returned: 
  Tautulli URL - http://localhost:8181
  Tautulli Public URL - https://tautulli.domain.com/
  Verify SSL - False
  Tautulli API key - xxxxxxxxxxxxxxxxxxxxxxxxxxxx53fd
  Successfully called Tautulli API cmd 'get_activity'
  Successfully called Tautulli API cmd 'terminate_session'
  Tautulli API cmd 'notify' failed: Notification failed.
2019-12-04 11:06:54 - INFO    :: Thread-15 : Tautulli Notifiers :: Script notification sent.
2019-12-04 11:08:21 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 49 paused.
2019-12-04 11:08:21 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Session 49 stopped.
2019-12-04 11:08:21 - INFO    :: Thread-2 : Tautulli NotificationHandler :: Preparing notification for notifier_id 3.
2019-12-04 11:08:21 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Trying to run notify script, action: pause, arguments: [u'--jbop', u'paused', u'--sessionId', '', u'--killMessage', u'Your stream was paused for over 20 minutes and has been automatically stopped for you.', u'--notify', u'4', u'--richMessage', u'slack', u'--serverName', u'Cloud', u'--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F45690', u'--posterUrl', '', u'--richColor', u'#E5A00D', u'--debug']
2019-12-04 11:08:21 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Full script is: ['python', u'/scripts/tautulli/killstream/kill_stream.py', '--jbop', 'paused', '--sessionId', '', '--killMessage', 'Your stream was paused for over 20 minutes and has been automatically stopped for you.', '--notify', '4', '--richMessage', 'slack', '--serverName', 'Cloud', '--plexUrl', 'https://app.plex.tv/desktop#!/server/********bf/details?key=%2Flibrary%2Fmetadata%2F45690', '--posterUrl', '', '--richColor', '#E5A00D', '--debug']
2019-12-04 11:08:21 - DEBUG   :: Thread-2 : Tautulli Notifiers :: Executing script in a new thread.
2019-12-04 11:08:21 - DEBUG   :: Thread-3 : Tautulli ActivityProcessor :: Play duration for session 49 ratingKey 45690 is 88 secs which is less than 120 seconds, so we're not logging it.
2019-12-04 11:08:21 - DEBUG   :: Thread-3 : Tautulli ActivityHandler :: Removing sessionKey 49 ratingKey 45690 from session queue
2019-12-04 11:08:21 - DEBUG   :: Thread-16 : Tautulli Notifiers :: Subprocess returned with status code 1.
2019-12-04 11:08:21 - ERROR   :: Thread-16 : Tautulli Notifiers :: Script error: 
  No sessionId provided! Is this synced content?
2019-12-04 11:08:21 - INFO    :: Thread-16 : Tautulli Notifiers :: Script notification sent.
2019-12-04 11:08:32 - INFO    :: MainThread : Signal 15 caught, saving and exiting...
2019-12-04 11:08:32 - INFO    :: MainThread : Stopping Tautulli web server...
2019-12-04 11:08:32 - INFO    :: MainThread : Tautulli WebSocket :: Disconnecting websocket...
2019-12-04 11:08:32 - DEBUG   :: Thread-3 : Tautulli WebSocket :: Leaving thread.
2019-12-04 11:08:33 - INFO    :: Thread-1 : Tautulli NotificationHandler :: Notification thread exiting...
2019-12-04 11:08:33 - INFO    :: Thread-2 : Tautulli NotificationHandler :: Notification thread exiting...
2019-12-04 11:08:33 - INFO    :: MainThread : Tautulli Config :: Writing configuration to file
2019-12-04 11:08:33 - INFO    :: MainThread : Tautulli is shutting down...
blacktwin commented 4 years ago

Try downloading the latest version of the script and may need to wait for the Tautulli's nightly branch to be pushed to master or you can see the edits to the branch. Or change the default subject/body to a blank string '' instead of None as a temporary workaround.

notification = Notification(notifier_id, None, None, tautulli, stream)
# to
notification = Notification(notifier_id, "", "", tautulli, stream)
m1lkman commented 4 years ago

That was it, checked out nightly and now it's working. Thank you @blacktwin for your help. I appreciate your responsiveness.