Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plex Sensor stays unavailable after server restart, is behind reverse proxy #67402

Closed
andrey-yantsen opened this issue Feb 28, 2022 · 7 comments · Fixed by #69822
Closed

Plex Sensor stays unavailable after server restart, is behind reverse proxy #67402

andrey-yantsen opened this issue Feb 28, 2022 · 7 comments · Fixed by #69822
Assignees

Comments

@andrey-yantsen
Copy link

andrey-yantsen commented Feb 28, 2022

The problem

I have Plex "hidden" behind Traefik. When the Plex server is down, the URL could return 502 bad gateway or 404 not found errors (I have HA and Plex set up in different locations, so I can't use a direct connection).

Today Plex was restarted (during the regular container upgrades), and the Plex integration in HA says Failed to set up ever since. The last error in the logs is the following:

Source: components/plex/__init__.py:152 
Login to PlexServerName failed, verify token and SSL settings: [(502) bad_gateway; https://example.com/ Bad Gateway]

From what I can see — the reason is in this code:

except (
plexapi.exceptions.BadRequest,
plexapi.exceptions.NotFound,
) as error:
_LOGGER.error(
"Login to %s failed, verify token and SSL settings: [%s]",
entry.data[CONF_SERVER],
error,
)
return False

but I'm not sure what would be the best solution here.

What version of Home Assistant Core has the issue?

2022.2.9

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

plex

Link to integration documentation on our website

https://www.home-assistant.io/integrations/plex/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

plex documentation
plex source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @jjlawren, mind taking a look at this issue as it has been labeled with an integration (plex) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@github-actions github-actions bot added the stale label Mar 30, 2022
@andrey-yantsen
Copy link
Author

Non-stale

@github-actions github-actions bot removed the stale label Apr 3, 2022
@jjlawren
Copy link
Contributor

jjlawren commented Apr 7, 2022

This is the fallback portion of the try/catch for unexpected errors like 404/502.

Are you saying that even after the Plex server is running again and Traefik is properly serving in front that the HA Plex integration still will not connect? If it hits this error it should retry until it's able to successfully connect again.

@andrey-yantsen
Copy link
Author

@jjlawren, yes, you understood me correctly. You fixed a somewhat similar issue #32071 by replacing return False with raise ConfigEntryNotReady — that's why I'm guessing that quoted code is the reason behind my problem.

@jjlawren
Copy link
Contributor

I agree with your suggested approach, thanks for taking a look. Sorry it took a while for such a simple fix, hopefully this will prevent your issue from recurring.

@andrey-yantsen
Copy link
Author

Thank you for the fix! :)

@github-actions github-actions bot locked and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants