diff --git a/Models/DeviceModel.cs b/Models/DeviceModel.cs index 2dd9ca0..366708b 100644 --- a/Models/DeviceModel.cs +++ b/Models/DeviceModel.cs @@ -57,7 +57,8 @@ public async Task SendNotifications(GotifyMessage iGotifyMessage, WebsocketClien } var ntfy = new SecNtfy(Environments.secNtfyUrl); - _ = ntfy.SendNotification(usr.DeviceToken, title, msg, iGotifyMessage.priority == 10, imageUrl, + var response = await ntfy.SendNotification(usr.DeviceToken, title, msg, iGotifyMessage.priority == 10, imageUrl, iGotifyMessage.priority); + Console.WriteLine(response); } } \ No newline at end of file diff --git a/Services/GotifySocketService.cs b/Services/GotifySocketService.cs index cbad7e6..a261973 100644 --- a/Services/GotifySocketService.cs +++ b/Services/GotifySocketService.cs @@ -286,8 +286,6 @@ private void StartConnection(List userList, string secntfyUrl) StartConnection(userList, secntfyUrl); return; } - - isSecNtfyAvailable = SecNtfy.CheckIfUrlReachable(secntfyUrl) ? "yes" : "no"; } catch { @@ -295,6 +293,21 @@ private void StartConnection(List userList, string secntfyUrl) StartDelayedConnection(userList, secntfyUrl); return; } + + try + { + bool isSecNtfyAvailableBool = SecNtfy.CheckIfUrlReachable(secntfyUrl); + isSecNtfyAvailable = isSecNtfyAvailableBool ? "yes" : "no"; + + if (!isSecNtfyAvailableBool) + Console.WriteLine($"SecNtfy Server: '{secntfyUrl}' is not available, please check your internet connection!"); + } + catch + { + Console.WriteLine($"SecNtfy Server: '{secntfyUrl}' is not available try to reconnect in 10s."); + StartDelayedConnection(userList, secntfyUrl); + return; + } Console.WriteLine($"Gotify - Url: {user.GotifyUrl}"); Console.WriteLine($"Is Gotify - Url available: {isGotifyAvailable}"); diff --git a/Services/WebSockClient.cs b/Services/WebSockClient.cs index deb0d6a..947e248 100644 --- a/Services/WebSockClient.cs +++ b/Services/WebSockClient.cs @@ -79,9 +79,18 @@ public void Start(string clientToken, bool isRestart = false) Start(wsName, true); break; case DisconnectionType.Error: - Console.WriteLine( - $"Webseocket Reconnection failed with Error. Try to reconnect ClientToken: {wsName} in 10s."); - ReconnectDelayed(wsName); + if (type.Exception != null && type.Exception.Message.Contains("401")) + { + Console.WriteLine($"ClientToken: {wsName} is not authorized and returned a 401 Unauthorized error! Skipping reconnection..."); + Stop(); + } + else + { + Console.WriteLine( + $"Webseocket Reconnection failed with Error. Try to reconnect ClientToken: {wsName} in 10s."); + ReconnectDelayed(wsName); + } + break; case DisconnectionType.Exit: break; diff --git a/iGotify Notification Assist.csproj b/iGotify Notification Assist.csproj index 6e787d9..13c86e3 100644 --- a/iGotify Notification Assist.csproj +++ b/iGotify Notification Assist.csproj @@ -6,16 +6,15 @@ enable true iGotify_Notification_Assist - 1.5.1.0 - 1.5.1.0 - 1.5.1.0 + 1.5.1.1 + 1.5.1.1 + 1.5.1.1 default - diff --git a/iGotifyNotificationAssist.sln.DotSettings.user b/iGotifyNotificationAssist.sln.DotSettings.user index 7b62790..8080162 100644 --- a/iGotifyNotificationAssist.sln.DotSettings.user +++ b/iGotifyNotificationAssist.sln.DotSettings.user @@ -5,6 +5,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded