ajnart / homarr

Customizable browser's home page to interact with your homeserver's Docker containers (e.g. Sonarr/Radarr)
https://homarr.dev
MIT License
6.01k stars 275 forks source link

Status checker issue: JSON.parse: unexpected character at line 1 column 1 of the JSON data #1727

Open pbarone opened 10 months ago

pbarone commented 10 months ago

Environment

Docker

Version

No response

Describe the problem

When using the status checker to report if a service is up, for a number of the tiles I have I get a red dot with an error message saying JSON.parse: unexpected character at line 1 column 1 of the JSON data

This happens for sonarr, radarr, plex, jellyfin, tautulli and more

Is there something I can do to fix this?

Logs

No response

Context

No response

Please tick the boxes

lersveen commented 9 months ago

I'm experiencing the same error message for everything I've tried – Plex, Sonarr, Radarr, Overseerr, Qbittorrent. Also seeing the widgets from these apps being slow and unstable. The exact same dashboard worked before upgrading to 0.14.x.

The behaviour of the status dot is also not consistent. It's usually red, but entering edit mode typically makes it green immediately. Going out of edit mode it will stay green. Refresh the page and it's red again.

It might also be relevant that all the apps have internal addresses without TLS, e.g. http://radarr:7878 where this is a hostname handled by Podmans internal DNS, but I know the Homarr container is able to resolve the hostnames and gets a 200 response. Could still be something related to DNS or plain HTTP though.

manuel-rw commented 9 months ago

@Meierschlumpf can you look into this?

Meierschlumpf commented 9 months ago

@pbarone @lersveen can someone of you send the docker logs you get when it gives you the error

pbarone commented 9 months ago

running "docker logs homarr" I get this (after a fresh restart of the container):

Exporting hostname... Migrating database... yarn run v1.22.19 $ ts-node ./migrate.ts Done in 3.13s. Starting production server... Listening on port 7575 url: http://daa028722984:7575

ERROR Unexpected response: Maximum number of redirects exceeded

Then after running it for a while I get a lot of the "ERROR Unexpected response: Maximum number of redirects exceeded" entries

Is this helpful?

Meierschlumpf commented 9 months ago

Okay it seems like there is an issue with at least one of the apps. At least one of the apps is redirecting in a loop, maybe because we are not authenticated. Can you find out which app is having this behaviour. Easiest to do so is to disable pings for each app until you can refresh and the pings work.

lersveen commented 9 months ago

I don't have any redirect errors in the server logs, in fact nothing is logged server side about this.

I'm getting the below error message on all apps, even e.g. http://radarr:7878/ping, which I've verified is returning JSON:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 29 Dec 2023 13:14:36 GMT
Server: Kestrel
Cache-Control: max-age=31536000, public
Last-Modified: Fri, 10 Nov 2023 03:50:40 GMT
Transfer-Encoding: chunked

{
  "status": "OK"
}
Skjermbilde 2023-12-29 kl  13 49 55

Browser console

In the browser console I get something like this when it fails:

Skjermbilde 2023-12-29 kl  13 58 49

The full URL that gives HTTP 500 (parameters decoded and hostname removed): https://HOSTNAME/api/trpc/app.ping,app.ping,app.ping,app.ping,app.ping,app.ping,mediaRequest.allMedia?batch=1&input={"0":{"json":{"id":"edee3980-ad66-4657-9bd1-121d93a0efab","configName":"default"}},"1":{"json":{"id":"2425deef-63d0-4931-8bdd-ee769b2d5cf1","configName":"default"}},"2":{"json":{"id":"4066785d-ce83-4e6d-af38-137e1d5d92c1","configName":"default"}},"3":{"json":{"id":"4411603d-e446-4370-a54a-21dc9108ddad","configName":"default"}},"4":{"json":{"id":"2f673888-e927-4bc7-892d-f8da875fdced","configName":"default"}},"5":{"json":{"id":"bf7407b2-fcf2-480a-b0cc-baca1e90c935","configName":"default"}},"6":{"json":{"configName":"default","widget":{"id":"ba8dfb94-02b7-49e3-8d3c-56cd2eb92849","type":"media-requests-stats","properties":{"replaceLinksWithExternalHost":false,"openInNewTab":true},"area":{"type":"wrapper","properties":{"id":"default"}},"shape":{"sm":{"location":{"x":0,"y":0},"size":{"width":2,"height":2}},"md":{"location":{"x":0,"y":0},"size":{"width":2,"height":2}},"lg":{"location":{"x":5,"y":0},"size":{"width":3,"height":2}}}}}}}

When I enter, then exit edit mode and get HTTP 200 – I get this:

Skjermbilde 2023-12-29 kl  14 19 57

And the URL (again parameters decoded and hostname removed): https://homarr.andre.party/api/trpc/app.ping,app.ping,app.ping,app.ping,app.ping,app.ping?batch=1&input={"0":{"json":{"id":"edee3980-ad66-4657-9bd1-121d93a0efab","configName":"default"}},"1":{"json":{"id":"2425deef-63d0-4931-8bdd-ee769b2d5cf1","configName":"default"}},"2":{"json":{"id":"4066785d-ce83-4e6d-af38-137e1d5d92c1","configName":"default"}},"3":{"json":{"id":"4411603d-e446-4370-a54a-21dc9108ddad","configName":"default"}},"4":{"json":{"id":"2f673888-e927-4bc7-892d-f8da875fdced","configName":"default"}},"5":{"json":{"id":"bf7407b2-fcf2-480a-b0cc-baca1e90c935","configName":"default"}}}

When I try to open both of those manually in a browser I get the same 500 and 200 responses, the 200 one giving me a JSON response like this:

[
   {
      "result":{
         "data":{
            "json":{
               "status":200,
               "statusText":"OK",
               "state":"online"
            }
         }
      }
   },
   {
      "result":{
         "data":{
            "json":{
               "status":200,
               "statusText":"OK",
               "state":"online"
            }
         }
      }
   }
]

Edit: Fixed wrong (same) URL for the 200 response. The difference between them is the one that fails has mediaRequest.allMedia and a corresponding element in the input parameter JSON.

lersveen commented 9 months ago

Ok, so to test a bit further I created a new dashboard with ONLY an app tile for Plex. It works perfectly. Then I added a widget and the same issue is back. So the problem seems to be that the batch requests with both pings and widget data fail. This also explains why I'm having the related issues of widgets not loading properly.

Edit: More specifically, the issue is with the Overseerr integration and the widgets Media request stats and Media Requests. Removing those, everything works fine. It is probably the ones getting the biggest amount of data and the requests between Homarr and Overseerr might take a little time. Could be about timeouts or something? Both those widgets do get their data sporadically.

Unsure what the solution here is, but probably making those batch requests a bit more robust? Maybe getting the widget data in separate requests, async?

Edit 2: I realize my issue might not be exactly the same as what @pbarone is experiencing, but still seems plausibly related.

github-actions[bot] commented 7 months ago

Hello 👋, this issue has been open for 60 days without activity. We mark issues to help prioritise and close dead issues. Can you confirm that this issue is still relevant on the latest version? I'll remove the stale label as soon as there is further activity on this issue. Thank you 🙏

lersveen commented 7 months ago

Can confirm that my issue is still present on Homarr 0.15.0.

Could this be prioritized? This effectively breaks both the Media request stats and Media Requests widgets.

Happy to assist further if you're not immediately able to reproduce the issue!

github-actions[bot] commented 5 months ago

Hello 👋, this issue has been open for 60 days without activity. We mark issues to help prioritise and close dead issues. Can you confirm that this issue is still relevant on the latest version? I'll remove the stale label as soon as there is further activity on this issue. Thank you 🙏

manuel-rw commented 4 months ago

Hi, this will be fixed in 1.0 (see #1993 for further information)