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 (2x) #1394

Merged
merged 4 commits into from
Jan 10, 2020
Merged
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
11 changes: 10 additions & 1 deletion neo/Network/RPC/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ public sealed class RpcServer : IDisposable
{
public Wallet Wallet { get; set; }
public Fixed8 MaxGasInvoke { get; }
public int MaxConcurrentConnections { get; }

private IWebHost host;
private readonly NeoSystem system;

public RpcServer(NeoSystem system, Wallet wallet = null, Fixed8 maxGasInvoke = default(Fixed8))
public RpcServer(NeoSystem system, Wallet wallet = null, Fixed8 maxGasInvoke = default(Fixed8), int maxConcurrentConnections = Peer.DefaultMaxConnections)
{
this.system = system;
this.Wallet = wallet;
this.MaxGasInvoke = maxGasInvoke;
this.MaxConcurrentConnections = maxConcurrentConnections;
}

private static JObject CreateErrorResponse(JObject id, int code, string message, JObject data = null)
Expand Down Expand Up @@ -361,6 +363,13 @@ public void Start(IPAddress bindAddress, int port, string sslCert = null, string
{
host = new WebHostBuilder().UseKestrel(options => options.Listen(bindAddress, port, listenOptions =>
{
// Default value is unlimited
options.Limits.MaxConcurrentConnections = MaxConcurrentConnections;
// Default value is 2 minutes
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(1);
// Default value is 30 seconds
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(15);

vncoelho marked this conversation as resolved.
Show resolved Hide resolved
if (string.IsNullOrEmpty(sslCert)) return;
listenOptions.UseHttps(sslCert, password, httpsConnectionAdapterOptions =>
{
Expand Down