From 6c629700d291a53ab6986f89d26d5fd7d06e0e8d Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 13 Jan 2020 14:07:31 +0100 Subject: [PATCH] Allow to configure MaxConcurrentConnections --- src/RpcServer/RpcServer.cs | 2 +- src/RpcServer/RpcServer/config.json | 1 + src/RpcServer/Settings.cs | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/RpcServer/RpcServer.cs b/src/RpcServer/RpcServer.cs index 91280c699..ee027543e 100644 --- a/src/RpcServer/RpcServer.cs +++ b/src/RpcServer/RpcServer.cs @@ -92,7 +92,7 @@ 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 = Peer.DefaultMaxConnections; + options.Limits.MaxConcurrentConnections = Settings.Default.MaxConcurrentConnections; // Default value is 2 minutes options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(1); // Default value is 30 seconds 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..f225ef393 100644 --- a/src/RpcServer/Settings.cs +++ b/src/RpcServer/Settings.cs @@ -17,7 +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; } private Settings(IConfigurationSection section) @@ -32,6 +32,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)