Skip to content

Commit

Permalink
Rpc limits (2x) (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon authored and erikzhang committed Jan 10, 2020
1 parent a1ea920 commit 54d0f29
Showing 1 changed file with 10 additions and 1 deletion.
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);

if (string.IsNullOrEmpty(sslCert)) return;
listenOptions.UseHttps(sslCert, password, httpsConnectionAdapterOptions =>
{
Expand Down

0 comments on commit 54d0f29

Please sign in to comment.