diff --git a/Desktop.Core/Services/CasterSocket.cs b/Desktop.Core/Services/CasterSocket.cs index d85dd98d..dc69873c 100644 --- a/Desktop.Core/Services/CasterSocket.cs +++ b/Desktop.Core/Services/CasterSocket.cs @@ -59,10 +59,14 @@ namespace Remotely.Desktop.Core.Services { try { - if (Connection != null) + if (Connection?.State == HubConnectionState.Connected) { - await Connection.StopAsync(); - await Connection.DisposeAsync(); + try + { + await Connection.StopAsync(); + await Connection.DisposeAsync(); + } + catch { } } Connection = new HubConnectionBuilder() .WithUrl($"{host}/CasterHub") diff --git a/Desktop.Linux/ViewModels/MainWindowViewModel.cs b/Desktop.Linux/ViewModels/MainWindowViewModel.cs index f94f3686..60b577fe 100644 --- a/Desktop.Linux/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Linux/ViewModels/MainWindowViewModel.cs @@ -206,7 +206,7 @@ namespace Remotely.Desktop.Linux.ViewModels } prompt.Owner = MainWindow.Current; await prompt.ShowDialog(MainWindow.Current); - var result = prompt.ViewModel.Host; + var result = prompt.ViewModel.Host?.TrimEnd('/'); if (result is null) { @@ -219,7 +219,7 @@ namespace Remotely.Desktop.Linux.ViewModels } if (result != Host) { - Host = result.TrimEnd('/'); + Host = result; var config = ConfigService.GetConfig(); config.Host = Host; ConfigService.Save(config); diff --git a/Desktop.Win/ViewModels/MainWindowViewModel.cs b/Desktop.Win/ViewModels/MainWindowViewModel.cs index a89fcea5..315a7b4a 100644 --- a/Desktop.Win/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Win/ViewModels/MainWindowViewModel.cs @@ -251,14 +251,14 @@ namespace Remotely.Desktop.Win.ViewModels } prompt.Owner = App.Current?.MainWindow; prompt.ShowDialog(); - var result = prompt.ViewModel.Host; + var result = prompt.ViewModel.Host?.TrimEnd('/'); if (!result.StartsWith("https://") && !result.StartsWith("http://")) { result = $"https://{result}"; } if (result != Host) { - Host = result.TrimEnd('/'); + Host = result; var config = ConfigService.GetConfig(); config.Host = Host; ConfigService.Save(config);