Sonarr / Sonarr

Smart PVR for newsgroup and bittorrent users.
https://sonarr.tv
GNU General Public License v3.0
10.17k stars 1.26k forks source link

Sonarr connections NTFY fails to authorize even though a valid token is passed. #6773

Closed Zaxiure closed 1 month ago

Zaxiure commented 1 month ago

Is there an existing issue for this?

Current Behavior

When connecting Sonarr to my ntfy server, both of which are behind an external reverse proxies (caddy) and are able to connect to one another. it's giving me an unauthorized behaviour. I also tried using the username / password combination but to no avail.

Both ntfy and sonarr are running in docker containers, which have a reverse proxy (caddy) on an external server. Which has IP whitelisting

Expected Behavior

I expect it to connect succesfully.

Steps To Reproduce

Settings -> Connect -> Add connection -> ntfy.sh Fill in URL for your server, pass the token you've created either in NTFY web ui or CLI ntfy token add <username> and subscribe to your defined channel

Environment

- OS: Arch Linux Latest
- Sonarr: 4.0.4.1491
- Docker Install: Yes
- Using Reverse Proxy: Yes
- Browser: Chrome 
- Database: Sqlite 3.44.2

What branch are you running?

Main

Trace Logs?

2024-05-01 08:08:33.7|Debug|Api|[GET] /api/v3/command: 200.OK (0 ms)
2024-05-01 08:08:33.7|Debug|Api|[GET] /api/v3/log/file: 200.OK (0 ms)
2024-05-01 08:08:35.4|Debug|Api|[GET] /api/v3/wanted/missing?page=1&pageSize=20&sortDirection=descending&sortKey=airDateUtc&monitored=true: 200.OK (12 ms)
2024-05-01 08:08:35.5|Debug|Api|[GET] /api/v3/queue/details?episodeIds=4472&episodeIds=5058&episodeIds=5057&episodeIds=5056&episodeIds=5055&episodeIds=5054&episodeIds=5053&episodeIds=5052&episodeIds=5051&episodeIds=5050&episodeIds=5049&episodeIds=5048&episodeIds=5047&episodeIds=5046&episodeIds=5045&episodeIds=5044&episodeIds=5043&episodeIds=5042&episodeIds=5041&episodeIds=5040: 200.OK (0 ms)
2024-05-01 08:08:35.5|Debug|Api|[GET] /api/v3/health: 200.OK (0 ms)
2024-05-01 08:08:38.9|Debug|Api|[GET] /api/v3/notification: 200.OK (0 ms)
2024-05-01 08:08:39.7|Debug|Api|[GET] /api/v3/notification/schema: 200.OK (14 ms)
2024-05-01 08:08:55.1|Warn|HttpClient|HTTP Error - Res: HTTP/2.0 [POST] https://REDACTED/sonarr?title=Sonarr%20-%20Test%20Notification&message=This%20is%20a%20test%20message%20from%20Sonarr&priority=3: 403.Forbidden (0 bytes)
2024-05-01 08:08:55.1|Error|NtfyProxy|Authorization is required

[v4.0.4.1491] NzbDrone.Common.Http.HttpException: HTTP request failed: [403:Forbidden] [POST] at [https://REDACTED/sonarr?title=Sonarr%20-%20Test%20Notification&message=This%20is%20a%20test%20message%20from%20Sonarr&priority=3]
   at NzbDrone.Common.Http.HttpClient.ExecuteAsync(HttpRequest request) in ./Sonarr.Common/Http/HttpClient.cs:line 119
   at NzbDrone.Common.Http.HttpClient.Execute(HttpRequest request) in ./Sonarr.Common/Http/HttpClient.cs:line 128
   at NzbDrone.Core.Notifications.Ntfy.NtfyProxy.SendNotification(String title, String message, HttpRequestBuilder requestBuilder, NtfySettings settings) in ./Sonarr.Core/Notifications/Ntfy/NtfyProxy.cs:line 152

2024-05-01 08:08:55.1|Error|NtfyProxy|Invalid token

[v4.0.4.1491] NzbDrone.Common.Http.HttpException: HTTP request failed: [403:Forbidden] [POST] at [https://REDACTED/sonarr?title=Sonarr%20-%20Test%20Notification&message=This%20is%20a%20test%20message%20from%20Sonarr&priority=3]
   at NzbDrone.Common.Http.HttpClient.ExecuteAsync(HttpRequest request) in ./Sonarr.Common/Http/HttpClient.cs:line 119
   at NzbDrone.Common.Http.HttpClient.Execute(HttpRequest request) in ./Sonarr.Common/Http/HttpClient.cs:line 128
   at NzbDrone.Core.Notifications.Ntfy.NtfyProxy.SendNotification(String title, String message, HttpRequestBuilder requestBuilder, NtfySettings settings) in ./Sonarr.Core/Notifications/Ntfy/NtfyProxy.cs:line 152
   at NzbDrone.Core.Notifications.Ntfy.NtfyProxy.SendNotification(String title, String message, NtfySettings settings) in ./Sonarr.Core/Notifications/Ntfy/NtfyProxy.cs:line 47
   at NzbDrone.Core.Notifications.Ntfy.NtfyProxy.Test(NtfySettings settings) in ./Sonarr.Core/Notifications/Ntfy/NtfyProxy.cs:line 111

2024-05-01 08:08:55.1|Warn|SonarrErrorPipeline|Invalid request Validation failed: 
 -- AccessToken: Access Token is invalid
2024-05-01 08:08:55.1|Debug|Api|[POST] /api/v3/notification/test: 400.BadRequest (192 ms)
2024-05-01 08:08:57.2|Debug|Api|[GET] /api/v3/health: 200.OK (1 ms)
2024-05-01 08:08:57.2|Debug|Api|[GET] /api/v3/system/status: 200.OK (2 ms)
2024-05-01 08:08:57.3|Debug|Api|[GET] /api/v3/diskspace: 200.OK (21 ms)
2024-05-01 08:08:58.2|Debug|Api|[GET] /api/v3/log?page=1&pageSize=50&sortDirection=descending&sortKey=time: 200.OK (19 ms)
2024-05-01 08:08:58.6|Debug|Api|[GET] /api/v3/log/file: 200.OK (0 ms)

Anything else?

image image
bakerboy448 commented 1 month ago

Are you connecting sonarr to ntfy through your reverse proxy? If so that's your issue and there's 0 reason to do so. Your proxy is blocking the request. There's no reason to go outside to change rooms when you can stay inside and go down the hallway. (I.e. use container names assuming they're on the same custom bridge network and remove the proxy from the equation and single point of failure)

Zaxiure commented 1 month ago

Yeah I was, actually just found out my Sonarr instance in docker was connected through gluetun causing the reverse proxy not to work.