Skip to content

Commit

Permalink
Remove ServicePointManager usage (#4020)
Browse files Browse the repository at this point in the history
* Remove ServicePointManager usage from acceptance tests since generally .NET is moving away from ServicePointManager

* Remove HttpDefaultConnectionLimit since the setting doesn't make sense anymore with modern HTTP Client usage.

We have decided against adding a log warning since generally it is OK to have settings in app.config that are no longer relevant.
  • Loading branch information
danielmarbach committed Mar 20, 2024
1 parent e870991 commit 8c6fd7d
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 61 deletions.
@@ -1,7 +1,6 @@
namespace ServiceControl.AcceptanceTesting.EndpointTemplates
{
using System;
using System.Net;
using System.Threading.Tasks;
using AcceptanceTesting;
using NServiceBus;
Expand All @@ -19,8 +18,6 @@ protected DefaultServerBase() : this(new ConfigureEndpointLearningTransport())

public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizations, Func<EndpointConfiguration, Task> configurationBuilderCustomization)
{
ServicePointManager.DefaultConnectionLimit = 100;

var endpointConfiguration = new EndpointConfiguration(endpointCustomizations.EndpointName);

endpointConfiguration.Pipeline.Register(new StampDispatchBehavior(runDescriptor.ScenarioContext), "Stamps outgoing messages with session ID");
Expand Down
11 changes: 0 additions & 11 deletions src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs
Expand Up @@ -3,7 +3,6 @@ namespace ServiceControl.AcceptanceTests
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
Expand All @@ -20,18 +19,8 @@ namespace ServiceControl.AcceptanceTests
using TestSupport;

[TestFixture]
//[Parallelizable(ParallelScope.All)]
abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider
{
protected AcceptanceTest()
{
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
ServicePointManager.MaxServicePoints = int.MaxValue;
ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages).
ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports
ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections
}

public IDomainEvents DomainEvents => serviceControlRunnerBehavior.DomainEvents;
public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient;
public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions;
Expand Down
Expand Up @@ -53,7 +53,6 @@ async Task InitializeServiceControl(ScenarioContext context)
ProcessRetryBatchesFrequency = TimeSpan.FromSeconds(2),
TimeToRestartErrorIngestionAfterFailure = TimeSpan.FromSeconds(2),
MaximumConcurrencyLevel = 2,
HttpDefaultConnectionLimit = int.MaxValue,
DisableHealthChecks = true,
MessageFilter = messageContext =>
{
Expand Down
10 changes: 0 additions & 10 deletions src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs
Expand Up @@ -4,7 +4,6 @@ namespace ServiceControl.Audit.AcceptanceTests
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
Expand All @@ -21,15 +20,6 @@ namespace ServiceControl.Audit.AcceptanceTests
[TestFixture]
abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider
{
protected AcceptanceTest()
{
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
ServicePointManager.MaxServicePoints = int.MaxValue;
ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages).
ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports
ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections
}

public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient;
public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions;
protected IServiceProvider ServiceProvider => serviceControlRunnerBehavior.ServiceProvider;
Expand Down
Expand Up @@ -42,7 +42,6 @@ async Task InitializeServiceControl(ScenarioContext context)
{
TransportConnectionString = transportToUse.ConnectionString,
MaximumConcurrencyLevel = 2,
HttpDefaultConnectionLimit = int.MaxValue,
ServiceControlQueueAddress = "SHOULDNOTBEUSED",
MessageFilter = messageContext =>
{
Expand Down
Expand Up @@ -18,7 +18,6 @@
"AuditRetentionPeriod": "30.00:00:00",
"MaxBodySizeToStore": 102400,
"ServiceName": "Particular.ServiceControl.Audit",
"HttpDefaultConnectionLimit": 100,
"TransportConnectionString": null,
"MaximumConcurrencyLevel": 32,
"DataSpaceRemainingThreshold": 20,
Expand Down
3 changes: 0 additions & 3 deletions src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs
Expand Up @@ -41,9 +41,6 @@ static class HostApplicationBuilderExtensions
configuration.License(settings.LicenseFileText);
}

// .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit.
ServicePointManager.DefaultConnectionLimit = settings.HttpDefaultConnectionLimit;

var transportSettings = MapSettings(settings);
var transportCustomization = settings.LoadTransportCustomization();

Expand Down
2 changes: 0 additions & 2 deletions src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs
Expand Up @@ -35,7 +35,6 @@ public Settings(string serviceName, string transportType = null, string persiste
AuditRetentionPeriod = GetAuditRetentionPeriod();
Port = SettingsReader.Read(SettingsRootNamespace, "Port", 44444);
MaximumConcurrencyLevel = SettingsReader.Read(SettingsRootNamespace, "MaximumConcurrencyLevel", 32);
HttpDefaultConnectionLimit = SettingsReader.Read(SettingsRootNamespace, "HttpDefaultConnectionLimit", 100);
DataSpaceRemainingThreshold = GetDataSpaceRemainingThreshold();
ServiceControlQueueAddress = SettingsReader.Read<string>(SettingsRootNamespace, "ServiceControlQueueAddress");
TimeToRestartAuditIngestionAfterFailure = GetTimeToRestartAuditIngestionAfterFailure();
Expand Down Expand Up @@ -131,7 +130,6 @@ public int MaxBodySizeToStore

public string ServiceName { get; }

public int HttpDefaultConnectionLimit { get; set; }
public string TransportConnectionString { get; set; }
public int MaximumConcurrencyLevel { get; set; }
public int DataSpaceRemainingThreshold { get; set; }
Expand Down
Expand Up @@ -63,7 +63,6 @@ public OkObjectResult Config()
PerformanceTunning = new
{
settings.MaxBodySizeToStore,
settings.HttpDefaultConnectionLimit,
},
Transport = new
{
Expand Down
11 changes: 0 additions & 11 deletions src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs
Expand Up @@ -3,7 +3,6 @@ namespace ServiceControl.Monitoring.AcceptanceTests
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using AcceptanceTesting;
Expand All @@ -18,16 +17,6 @@ namespace ServiceControl.Monitoring.AcceptanceTests
[TestFixture]
abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProvider
{
protected AcceptanceTest()
{
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
ServicePointManager.MaxServicePoints = int.MaxValue;
ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages).
ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports
ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections
}


public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient;
public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions;

Expand Down
10 changes: 0 additions & 10 deletions src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs
Expand Up @@ -4,7 +4,6 @@ namespace ServiceControl.MultiInstance.AcceptanceTests
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using AcceptanceTesting;
Expand All @@ -20,15 +19,6 @@ namespace ServiceControl.MultiInstance.AcceptanceTests
[TestFixture]
abstract class AcceptanceTest : NServiceBusAcceptanceTest, IAcceptanceTestInfrastructureProviderMultiInstance
{
protected AcceptanceTest()
{
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
ServicePointManager.MaxServicePoints = int.MaxValue;
ServicePointManager.UseNagleAlgorithm = false; // Improvement for small tcp packets traffic, get buffered up to 1/2-second. If your storage communication is for small (less than ~1400 byte) payloads, this setting should help (especially when dealing with things like Azure Queues, which tend to have very small messages).
ServicePointManager.Expect100Continue = false; // This ensures tcp ports are free up quicker by the OS, prevents starvation of ports
ServicePointManager.SetTcpKeepAlive(true, 5000, 1000); // This is good for Azure because it reuses connections
}

protected static string ServiceControlInstanceName { get; } = Settings.DEFAULT_SERVICE_NAME;
protected static string ServiceControlAuditInstanceName { get; } = Audit.Infrastructure.Settings.Settings.DEFAULT_SERVICE_NAME;

Expand Down
Expand Up @@ -30,7 +30,6 @@
"ErrorRetentionPeriod": "10.00:00:00",
"EventsRetentionPeriod": "14.00:00:00",
"ServiceName": "Particular.ServiceControl",
"HttpDefaultConnectionLimit": 100,
"TransportConnectionString": null,
"ProcessRetryBatchesFrequency": "00:00:30",
"TimeToRestartErrorIngestionAfterFailure": "00:01:00",
Expand Down
3 changes: 0 additions & 3 deletions src/ServiceControl/HostApplicationBuilderExtensions.cs
Expand Up @@ -48,9 +48,6 @@ public static void AddServiceControl(this IHostApplicationBuilder hostBuilder, S
EventSourceCreator.Create();
}

// .NET default limit is 10. RavenDB in conjunction with transports that use HTTP exceeds that limit.
ServicePointManager.DefaultConnectionLimit = settings.HttpDefaultConnectionLimit;

var transportCustomization = settings.LoadTransportCustomization();
var transportSettings = MapSettings(settings);

Expand Down
2 changes: 0 additions & 2 deletions src/ServiceControl/Infrastructure/Settings/Settings.cs
Expand Up @@ -49,7 +49,6 @@ public class Settings
ProcessRetryBatchesFrequency = TimeSpan.FromSeconds(30);
MaximumConcurrencyLevel = SettingsReader.Read(SettingsRootNamespace, "MaximumConcurrencyLevel", 10);
RetryHistoryDepth = SettingsReader.Read(SettingsRootNamespace, "RetryHistoryDepth", 10);
HttpDefaultConnectionLimit = SettingsReader.Read(SettingsRootNamespace, "HttpDefaultConnectionLimit", 100);
AllowMessageEditing = SettingsReader.Read<bool>(SettingsRootNamespace, "AllowMessageEditing");
NotificationsFilter = SettingsReader.Read<string>(SettingsRootNamespace, "NotificationsFilter");
RemoteInstances = GetRemoteInstances().ToArray();
Expand Down Expand Up @@ -156,7 +155,6 @@ public TimeSpan HeartbeatGracePeriod
public TimeSpan EventsRetentionPeriod { get; }
public string ServiceName { get; }

public int HttpDefaultConnectionLimit { get; set; }
public string TransportConnectionString { get; set; }
public TimeSpan ProcessRetryBatchesFrequency { get; set; }
public TimeSpan TimeToRestartErrorIngestionAfterFailure { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/ServiceControl/Infrastructure/WebApi/RootController.cs
Expand Up @@ -78,7 +78,6 @@ public object Config()
},
PerformanceTunning = new
{
settings.HttpDefaultConnectionLimit,
settings.ExternalIntegrationsDispatchingBatchSize
},
PersistenceSettings = settings.PersisterSpecificSettings,
Expand Down

0 comments on commit 8c6fd7d

Please sign in to comment.