Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpc limits (3x) #172

Merged
merged 5 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/RpcServer/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
{
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" ]
}
}
2 changes: 2 additions & 0 deletions src/RpcServer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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<string>()).ToArray();
this.MaxConcurrentConnections = section.GetValue("MaxConcurrentConnections", 40);
}

public static void Load(IConfigurationSection section)
Expand Down