Skip to content

Make simple plex conn check#376

Closed
janw wants to merge 2 commits intoFoxxMD:masterfrom
janw:simple-plex-conn-check
Closed

Make simple plex conn check#376
janw wants to merge 2 commits intoFoxxMD:masterfrom
janw:simple-plex-conn-check

Conversation

@janw
Copy link
Copy Markdown

@janw janw commented Oct 28, 2025

Checklist before requesting a review

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Describe your changes

Fixes an issue with the plex connection check that would not work for me under v0.10.0 and plex URL setting similar to https://myplex.homelab.test. This is solved by simply avoiding to parse the URL altogether and checks connectivity by getting the server capabilities.

Test docker image available at ghcr.io/janw/multi-scrobbler:simple-plex-conn-check and verified to be working in my setup.

@FoxxMD
Copy link
Copy Markdown
Owner

FoxxMD commented Oct 29, 2025

Thank you for the contribution but I'd prefer to try to address the root cause of your issue first.

What issue were you having with isPortReachable? Can you provide logs of the error or describe what was insufficient with the method?

isPortReachable is a simpler method for "sanity" testing if anything exists at the user-provided address, or if there are networking issues preventing the address from being reached. I use it extensively in other Sources/Clients and it has simple, easy-to-read error logging that is helpful for non-technical users and for myself when diagnosing issues.

getServerCapabilities doesn't do the same kind of simple check and may fail for a number of other reasons that aren't related to networking such as the numerous occurrences where the plex library throws an error when api response does not match the library schema. I can't control how the plex library connects and validates connection so it would make it harder to determine if a user having connections issues is due to actual networking or something wrong with the library, if only getServerCapabilities was used.

Therefore, I'd prefer to correct whatever problem you were having when using isPortReachable so that I can preserve troubleshooting clarity for myself with future issues from other users.

@janw
Copy link
Copy Markdown
Author

janw commented Oct 29, 2025

[2025-10-29 14:23:19.367 +0100] INFO   : [App] [Heartbeat] [Sources] Attempted to start 1 sources.
[2025-10-29 14:23:19.360 +0100] ERROR  : [App] [Sources] [Plex - Plex] Could not initialize source automatically
Error: Could not initialize source automatically
    at PromisePoolExecutor.handler (CWD/src/backend/tasks/heartbeatSources.ts:26:49)
    at async PromisePoolExecutor.waitForActiveTaskToFinish (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:375:9)
    at async PromisePoolExecutor.waitForProcessingSlot (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:368:13)
    at async PromisePoolExecutor.process (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:354:13)
    at async PromisePoolExecutor.start (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:273:16)
caused by: Error: Initialization failed
    at PlexApiSource.initialize (CWD/src/backend/common/AbstractComponent.ts:84:19)
    at async PlexApiSource.tryInitialize (CWD/src/backend/common/AbstractComponent.ts:104:20)
    at async PromisePoolExecutor.handler (CWD/src/backend/tasks/heartbeatSources.ts:24:29)
    at async PromisePoolExecutor.waitForActiveTaskToFinish (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:375:9)
    at async PromisePoolExecutor.waitForProcessingSlot (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:368:13)
    at async PromisePoolExecutor.process (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:354:13)
    at async PromisePoolExecutor.start (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:273:16)
caused by: Connection Check: Communicating with upstream service failed
    at PlexApiSource.checkConnection (CWD/src/backend/common/AbstractComponent.ts:282:19)
    at async PlexApiSource.initialize (CWD/src/backend/common/AbstractComponent.ts:71:13)
    at async PlexApiSource.tryInitialize (CWD/src/backend/common/AbstractComponent.ts:104:20)
    at async PromisePoolExecutor.handler (CWD/src/backend/tasks/heartbeatSources.ts:24:29)
    at async PromisePoolExecutor.waitForActiveTaskToFinish (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:375:9)
    at async PromisePoolExecutor.waitForProcessingSlot (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:368:13)
    at async PromisePoolExecutor.process (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:354:13)
    at async PromisePoolExecutor.start (CWD/node_modules/@supercharge/promise-pool/dist/promise-pool-executor.js:273:16)
caused by: RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received type number (NaN).
    at lookupAndConnect (node:net:1302:5)
    at Socket.connect (node:net:1259:5)
    at <anonymous> (CWD/src/backend/utils/NetworkUtils.ts:36:16)
    at new Promise (<anonymous>)
    at isPortReachable (CWD/src/backend/utils/NetworkUtils.ts:20:21)
    at PlexApiSource.doCheckConnection (CWD/src/backend/sources/PlexApiSource.ts:136:37)
    at PlexApiSource.checkConnection (CWD/src/backend/common/AbstractComponent.ts:269:36)
    at PlexApiSource.initialize (CWD/src/backend/common/AbstractComponent.ts:71:24)
    at async PlexApiSource.tryInitialize (CWD/src/backend/common/AbstractComponent.ts:104:20)
    at async PromisePoolExecutor.handler (CWD/src/backend/tasks/heartbeatSources.ts:24:29)
[2025-10-29 14:23:19.357 +0100] INFO   : [App] Scheduler started.
[2025-10-29 14:23:18.341 +0100] INFO   : [App] [Heartbeat] [Clients] Attempted to start 1 clients that were not processing scrobbles.
[2025-10-29 14:23:18.341 +0100] INFO   : [App] [Scrobblers] [Listenbrainz - ListenBrainz] Scrobble processing started
[2025-10-29 14:23:18.339 +0100] INFO   : [App] [Scrobblers] [Listenbrainz - ListenBrainz] Should be processing scrobbles! Attempting to restart scrobbling...
    label: "Heartbeat"
[2025-10-29 14:23:17.594 +0100] INFO   : [App] [Scrobblers] [Listenbrainz - ListenBrainz] Fully Initialized!
[2025-10-29 14:23:17.354 +0100] INFO   : [App] [Sources] [Plex - Plex] Source Added from plex.json
[2025-10-29 14:23:17.215 +0100] INFO   : [App] [Scrobblers] [Listenbrainz - ListenBrainz] Client Added from listenbrainz.json
[2025-10-29 14:23:17.082 +0100] INFO   : [App] [API] Server started:
---> Local          http://localhost:9078
---> Network        http://10.42.0.87:9078
---> Network (IPv6) http://[2001:cafe:42::508f]:9078
[2025-10-29 14:23:16.951 +0100] INFO   : [Init] Schema definitions generated
[2025-10-29 14:23:14.383 +0100] INFO   : [Init] Generating schema definitions...
[2025-10-29 14:23:14.382 +0100] INFO   : [Init] Version: 0.10.0
[2025-10-29 14:23:14.365 +0100] INFO   : [Init] Debug Mode: NO
[2025-10-29 14:23:14.358 +0100] VERBOSE: [Init] Config Dir ENV: /config -> Resolved: /config

FoxxMD added a commit that referenced this pull request Oct 29, 2025
@FoxxMD
Copy link
Copy Markdown
Owner

FoxxMD commented Oct 29, 2025

Please try docker image foxxmd/multi-scrobbler:pr-377 and see if that fixes your issue.

@janw
Copy link
Copy Markdown
Author

janw commented Oct 30, 2025

Yes, that works, thanks.

@FoxxMD FoxxMD closed this Oct 30, 2025
FoxxMD added a commit that referenced this pull request Oct 30, 2025
fix(plex): Use better url parsing method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants