dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
878 stars 45 forks source link

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

Open denilsonsa opened 9 months ago

denilsonsa commented 9 months ago

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:

The error message is:

Could not reach server (wrong hostname?)

This URL works:

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:

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.