Skip to content

Commit

Permalink
Allow to configure MaxConcurrentConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Jan 13, 2020
1 parent 3bab226 commit 6c62970
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/RpcServer/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/RpcServer/RpcServer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"RpcPass": "",
"MaxGasInvoke": 10,
"MaxFee": 0.1,
"MaxConcurrentConnections": 40,
"DisabledMethods": [ "openwallet" ]
}
}
3 changes: 2 additions & 1 deletion src/RpcServer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<string>()).ToArray();
this.MaxConcurrentConnections = section.GetValue("MaxConcurrentConnections", 40);
}

public static void Load(IConfigurationSection section)
Expand Down

0 comments on commit 6c62970

Please sign in to comment.