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

Could not reach server - please normalize URLs while adding a server #304

Open
denilsonsa opened this issue Dec 21, 2023 · 0 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@denilsonsa
Copy link

When trying to set up my home Jellyfin server, I had some trouble. These URLs work just fine in a browser, but they don't work in the Supersonic configuration:

  • http://192.168.xx.xx:8096/web/index.html
  • http://192.168.xx.xx:8096/web/
  • http://192.168.xx.xx:8096/

The error message is:

Could not reach server (wrong hostname?)

This URL works:

  • http://192.168.xx.xx:8096

Note how the only difference is the lack of the trailing slash.

Proposed solutions

Since this issue is very similar to the one I just reported to Tauon Music Box, I'm gonna propose similar solutions.

Normalize the URL at the form

When the user types the URL, some basic normalization should be performed:

  • Strip away known URL suffixes to generate URL candidates.
    • http://192.168.xx.xx:8096/web/index.htmlhttp://192.168.xx.xx:8096/
    • http://192.168.xx.xx:8096/web/http://192.168.xx.xx:8096/
    • http://192.168.xx.xx:8096/mymusic/ stays as is. For unknown suffixes, it is likely the Jellyfin is being served as a subpath or using some kind of proxy.
    • http://192.168.xx.xx:8096/mymusic/index.htmlhttp://192.168.xx.xx:8096/mymusic/
    • http://192.168.xx.xx:8096/mymusic/web/index.htmlhttp://192.168.xx.xx:8096/mymusic/
  • Add http:// and https:// prefixes, if the protocol is not specified.
  • Add the common Jellyfin port(s) (e.g. :8096) if the port is not specified.
  • Collect all these candidate URLs by applying several rules and combining the rules.
  • Check if each of the normalized candidate URLs is a valid Jellyfin instance.
  • Update the form with the normalized URL that is valid.

Use a proper URL building function instead of concatenating strings

Blindly concatenating strings leads to trouble, like described here. Instead, a proper function or library should be used when building URLs.

Since it looks like Supersonic is using libraries for handling the jellyfin integration, fixing this should require fixing the libraries themselves.

Proper error message.

The error message is just plain wrong and misleading. The hostname was found. A proper, more descriptive, and more truthful error message should be used instead.

A server-not-found error message should be different than 404 (which probably means the server was found, but either the path is wrong or it is the wrong server).

As bonus, this kind of error (404 or wrong response) is detected in milliseconds. It shouldn't take several seconds to display the error.

@dweymouth dweymouth added good first issue Good for newcomers enhancement New feature or request labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants