From 9df196d1e80becb342a1ff8f193b51af8a3f336d Mon Sep 17 00:00:00 2001 From: Enzo Batista <111511512+Enzo707@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:11:05 -0300 Subject: [PATCH] DYN-6350 add request timeout for notification service (#14564) * add request timeout for notification service * refactor: implement an auto-property instead of a field for notifications request timeOut * set notification request timeOut of 10000ms * refactor: move notifications request timeOut as a constant within Dynamo Configuration --------- Co-authored-by: reddyashish <43763136+reddyashish@users.noreply.github.com> --- src/DynamoCore/Configuration/Configurations.cs | 7 +++++++ src/Notifications/NotificationCenterController.cs | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/DynamoCore/Configuration/Configurations.cs b/src/DynamoCore/Configuration/Configurations.cs index fa2a42ea0fd..bd42b49c333 100644 --- a/src/DynamoCore/Configuration/Configurations.cs +++ b/src/DynamoCore/Configuration/Configurations.cs @@ -429,5 +429,12 @@ internal static Dictionary SupportedUnits } #endregion + + #region Notifications Constants + /// + /// Request timeOut for notifications service + /// + public const int NotificationsDefaultTimeOut = 10000; + #endregion } } diff --git a/src/Notifications/NotificationCenterController.cs b/src/Notifications/NotificationCenterController.cs index 2706ab97bd0..7a8a1dd687c 100644 --- a/src/Notifications/NotificationCenterController.cs +++ b/src/Notifications/NotificationCenterController.cs @@ -17,6 +17,7 @@ using Newtonsoft.Json; using Microsoft.Web.WebView2.Wpf; using Dynamo.Utilities; +using Dynamo.Configuration; namespace Dynamo.Notifications { @@ -164,6 +165,7 @@ private void RequestNotifications() var uri = DynamoUtilities.PathHelper.GetServiceBackendAddress(this, "notificationAddress"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; + request.Timeout = Configurations.NotificationsDefaultTimeOut; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream())