Skip to content

Commit 13aa4a6

Browse files
committed
Resolving the „Dokcer Host Panic“ Issue #204
Issue 204: Docker experiences a panic response when encountering unauthorized or invalid Client Tokens in the users.db file. In response, it attempts to reconnect every 10 seconds. However, upon initial startup, the system checks for a 401 response. If a 401 response is detected, the reconnection process for this websocket is terminated, effectively resolving the panic issue experienced by the Docker host.
1 parent d4f9f3e commit 13aa4a6

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

Models/DeviceModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public async Task SendNotifications(GotifyMessage iGotifyMessage, WebsocketClien
5757
}
5858

5959
var ntfy = new SecNtfy(Environments.secNtfyUrl);
60-
_ = ntfy.SendNotification(usr.DeviceToken, title, msg, iGotifyMessage.priority == 10, imageUrl,
60+
var response = await ntfy.SendNotification(usr.DeviceToken, title, msg, iGotifyMessage.priority == 10, imageUrl,
6161
iGotifyMessage.priority);
62+
Console.WriteLine(response);
6263
}
6364
}

Services/GotifySocketService.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,28 @@ private void StartConnection(List<Users> userList, string secntfyUrl)
286286
StartConnection(userList, secntfyUrl);
287287
return;
288288
}
289-
290-
isSecNtfyAvailable = SecNtfy.CheckIfUrlReachable(secntfyUrl) ? "yes" : "no";
291289
}
292290
catch
293291
{
294292
Console.WriteLine($"Gotify Server: '{user.GotifyUrl}' is not available try to reconnect in 10s.");
295293
StartDelayedConnection(userList, secntfyUrl);
296294
return;
297295
}
296+
297+
try
298+
{
299+
bool isSecNtfyAvailableBool = SecNtfy.CheckIfUrlReachable(secntfyUrl);
300+
isSecNtfyAvailable = isSecNtfyAvailableBool ? "yes" : "no";
301+
302+
if (!isSecNtfyAvailableBool)
303+
Console.WriteLine($"SecNtfy Server: '{secntfyUrl}' is not available, please check your internet connection!");
304+
}
305+
catch
306+
{
307+
Console.WriteLine($"SecNtfy Server: '{secntfyUrl}' is not available try to reconnect in 10s.");
308+
StartDelayedConnection(userList, secntfyUrl);
309+
return;
310+
}
298311

299312
Console.WriteLine($"Gotify - Url: {user.GotifyUrl}");
300313
Console.WriteLine($"Is Gotify - Url available: {isGotifyAvailable}");

Services/WebSockClient.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,18 @@ public void Start(string clientToken, bool isRestart = false)
7979
Start(wsName, true);
8080
break;
8181
case DisconnectionType.Error:
82-
Console.WriteLine(
83-
$"Webseocket Reconnection failed with Error. Try to reconnect ClientToken: {wsName} in 10s.");
84-
ReconnectDelayed(wsName);
82+
if (type.Exception != null && type.Exception.Message.Contains("401"))
83+
{
84+
Console.WriteLine($"ClientToken: {wsName} is not authorized and returned a 401 Unauthorized error! Skipping reconnection...");
85+
Stop();
86+
}
87+
else
88+
{
89+
Console.WriteLine(
90+
$"Webseocket Reconnection failed with Error. Try to reconnect ClientToken: {wsName} in 10s.");
91+
ReconnectDelayed(wsName);
92+
}
93+
8594
break;
8695
case DisconnectionType.Exit:
8796
break;

iGotify Notification Assist.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<InvariantGlobalization>true</InvariantGlobalization>
88
<RootNamespace>iGotify_Notification_Assist</RootNamespace>
9-
<AssemblyVersion>1.5.1.0</AssemblyVersion>
10-
<FileVersion>1.5.1.0</FileVersion>
11-
<Version>1.5.1.0</Version>
9+
<AssemblyVersion>1.5.1.1</AssemblyVersion>
10+
<FileVersion>1.5.1.1</FileVersion>
11+
<Version>1.5.1.1</Version>
1212
<LangVersion>default</LangVersion>
1313
</PropertyGroup>
1414

1515
<ItemGroup>
1616
<PackageReference Include="Dapper" Version="2.1.66" />
1717
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
18-
<PackageReference Include="Dapper.Mapper" Version="2.0.0" />
1918
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
2019
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.0" />
2120
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />

iGotifyNotificationAssist.sln.DotSettings.user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASecNtfy_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb26cc17506944dd48fbdaecd1892512f3e00_003F53_003F3be8b167_003FSecNtfy_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
66
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASecNtfy_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb26cc17506944dd48fbdaecd1892512f3e00_003F53_003F3be8b167_003FSecNtfy_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
77
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASecNtfy_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb26cc17506944dd48fbdaecd1892512f3e00_003Fa2_003F95ee9bb0_003FSecNtfy_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
8+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASecNtfy_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb26cc17506944dd48fbdaecd1892512f3e00_003Fa2_003F95ee9bb0_003FSecNtfy_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
89
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqliteDataReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Ff74c15be4ebfb9eebdf1d29c607aa58a3dd7cfccafcbf075c7887256d97ccb40_003FSqliteDataReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
910
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStackFrameIterator_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F821eadf8c89b36691b3def72d04889d8d4cd791563a97558876f873a81a1a085_003FStackFrameIterator_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
1011
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa3aad6bae93c22cddbd7de9e546a684ecd4718317311a5292bf4707a11d0e3_003FThread_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

0 commit comments

Comments
 (0)