Skip to content

Feature: Implement local-network priority for Jellyfin server connections#502

Open
eamondo2 wants to merge 1 commit intojellyfin:masterfrom
eamondo2:prefer-local-server
Open

Feature: Implement local-network priority for Jellyfin server connections#502
eamondo2 wants to merge 1 commit intojellyfin:masterfrom
eamondo2:prefer-local-server

Conversation

@eamondo2
Copy link
Copy Markdown

I've got a mini-PC I bring with me when traveling, and I'd rather not have to switch the server configuration around between at-home or otherwise.

While the shim allows you to add multiple server connections, if you add the same Jellyfin server twice (from differing addresses, one local and one external) the behavior is a bit wonky currently.

The _connect_all() function call in clients.py currently attempts to connect to all configured servers one after another, and while I assume that works fine if you have multiple different servers to connect to, it clobbers the connection if two entries are resolvable but point to the same server. This means that if the entry pointing at the external host for your server is last in the cred.json file, it will connect after the local one has successfully connected, bouncing it and defaulting to that route. In my case this means it attempts to transcode, or at least marks the client as being outside of the local net for bandwidth limits etc.

The implementation in the clients.py might be a touch hacky, but the gist is to sort the list of servers looped over for connection, prioritized by ones pointing at a subnet matching any local IP the host is on. Then we stash the Id of the Jellyfin server successfully connected to, and continue looping over the remainder.
If an additional entry is hit with the same Id as one we've connected to successfully, we skip connecting and finish iterating over the remainder.

In theory this doesn't break the use-case where you have multiple, discrete Jellyfin servers you'd like your shim connected to, while allowing duplicate connections to the same servers via different endpoints to bail out once a valid connection has been made, and prefer a local direct IP connection if available.

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.

1 participant