diff --git a/src/RpcServer/RpcServer.cs b/src/RpcServer/RpcServer.cs index d263f3dac..ee027543e 100644 --- a/src/RpcServer/RpcServer.cs +++ b/src/RpcServer/RpcServer.cs @@ -91,6 +91,13 @@ protected override void OnPluginsLoaded() { host = new WebHostBuilder().UseKestrel(options => options.Listen(Settings.Default.BindAddress, Settings.Default.Port, listenOptions => { + // Default value is unlimited + options.Limits.MaxConcurrentConnections = Settings.Default.MaxConcurrentConnections; + // Default value is 2 minutes + options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(1); + // Default value is 30 seconds + options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(15); + if (string.IsNullOrEmpty(Settings.Default.SslCert)) return; listenOptions.UseHttps(Settings.Default.SslCert, Settings.Default.SslCertPassword, httpsConnectionAdapterOptions => { diff --git a/src/RpcServer/RpcServer/config.json b/src/RpcServer/RpcServer/config.json index 39d4639c0..d51daac31 100644 --- a/src/RpcServer/RpcServer/config.json +++ b/src/RpcServer/RpcServer/config.json @@ -9,6 +9,7 @@ "RpcPass": "", "MaxGasInvoke": 10, "MaxFee": 0.1, + "MaxConcurrentConnections": 40, "DisabledMethods": [ "openwallet" ] } } diff --git a/src/RpcServer/Settings.cs b/src/RpcServer/Settings.cs index d955e48d8..1b6a6acd6 100644 --- a/src/RpcServer/Settings.cs +++ b/src/RpcServer/Settings.cs @@ -17,6 +17,7 @@ internal class Settings public long MaxGasInvoke { get; } public long MaxFee { get; } public string[] DisabledMethods { get; } + public int MaxConcurrentConnections { get; } public static Settings Default { get; private set; } @@ -32,6 +33,7 @@ private Settings(IConfigurationSection section) this.MaxGasInvoke = (long)BigDecimal.Parse(section.GetValue("MaxGasInvoke", "10"), NativeContract.GAS.Decimals).Value; this.MaxFee = (long)BigDecimal.Parse(section.GetValue("MaxFee", "0.1"), NativeContract.GAS.Decimals).Value; this.DisabledMethods = section.GetSection("DisabledMethods").GetChildren().Select(p => p.Get()).ToArray(); + this.MaxConcurrentConnections = section.GetValue("MaxConcurrentConnections", 40); } public static void Load(IConfigurationSection section)