diff --git a/neo/Network/P2P/Connection.cs b/neo/Network/P2P/Connection.cs index a6ae95f8f5..b7a007ad62 100644 --- a/neo/Network/P2P/Connection.cs +++ b/neo/Network/P2P/Connection.cs @@ -19,12 +19,20 @@ public abstract class Connection : UntypedActor private readonly IActorRef tcp; private readonly WebSocket ws; private bool disconnected = false; + /// + /// connection initial timeout (in seconds) before any package has been accepted + /// + private double connectionTimeoutLimitStart = 10; + /// + /// connection timeout (in seconds) after every `OnReceived(ByteString data)` event + /// + private double connectionTimeoutLimit = 60; protected Connection(object connection, IPEndPoint remote, IPEndPoint local) { this.Remote = remote; this.Local = local; - this.timer = Context.System.Scheduler.ScheduleTellOnceCancelable(TimeSpan.FromSeconds(10), Self, Timer.Instance, ActorRefs.NoSender); + this.timer = Context.System.Scheduler.ScheduleTellOnceCancelable(TimeSpan.FromSeconds(connectionTimeoutLimitStart), Self, Timer.Instance, ActorRefs.NoSender); switch (connection) { case IActorRef tcp: @@ -100,7 +108,7 @@ protected override void OnReceive(object message) private void OnReceived(ByteString data) { timer.CancelIfNotNull(); - timer = Context.System.Scheduler.ScheduleTellOnceCancelable(TimeSpan.FromMinutes(1), Self, Timer.Instance, ActorRefs.NoSender); + timer = Context.System.Scheduler.ScheduleTellOnceCancelable(TimeSpan.FromSeconds(connectionTimeoutLimit), Self, Timer.Instance, ActorRefs.NoSender); try { OnData(data);