Skip to content

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

@denilsonsa

Description

@denilsonsa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions