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

Retry failed websocket connection when connecting to Plex #6

Open
bnjns opened this issue May 2, 2023 · 1 comment
Open

Retry failed websocket connection when connecting to Plex #6

bnjns opened this issue May 2, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@bnjns
Copy link

bnjns commented May 2, 2023

First of all, thanks so much for building this - love being able to monitor my plex server from Grafana!

I think this is related to the TODO in listener.go, but if you start the exporter before plex is ready then it fails to connect and doesn't retry, meaning you have to manually restart the exporter in order to then get metrics.

level=error msg="Get \"http://<ip>:32400/media/providers?includeStorage=1\": dial tcp <ip>:32400: connect: connection refused"
level=error msg="error in websocket processing" err="websocket: bad handshake"
level=info msg="Successfully connected" machineID= server=

I'm using Docker to run plex, the exporter, and the grafana agent. I've tried to mitigate by adding health checks to plex and configuring the exporter with a depends_on but it appears that's not enough when the computer starts up. Easily rectified with docker-compose restart exporter but I'd rather not have to remember to run this every day!

@liaralabs
Copy link

liaralabs commented May 13, 2023

I faced this issue with Kubernetes as well (thanks for even bringing this up.. I couldn't figure out why I wasn't getting playback metrics). The problem is a little harder to solve here because k8s doesn't really have a concept of dependencies. If you have more than one container in a pod they are always started simultaneously and there are longstanding issues regarding this problem open on the k8s project.

Regardless, for kubernetes, I managed to fix this with a healthcheck of sorts:

        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "if ! wget -O- --no-check-certificate 127.0.0.1:32400/web; then reboot; fi"]

This goes in the spec for the exporter container and seems to be working well. All this does is reach out the the plex server and reboot the exporter container if the plex server isn't ready yet.

@bnjns bnjns changed the title Retry failed websocker connection when connecting to Plex Retry failed websocket connection when connecting to Plex May 13, 2023
@jsclayton jsclayton added the bug Something isn't working label May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants