From 3ae5f69279ee2ac38dd8d0b2c0cf1feb58765f77 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 16 Sep 2019 09:17:20 +1000 Subject: [PATCH] Fixes #117 - apply --timeout to HttpClient --- seqcli.sln.DotSettings | 1 + src/SeqCli/Cli/Commands/QueryCommand.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/seqcli.sln.DotSettings b/seqcli.sln.DotSettings index 5daabd98..49256843 100644 --- a/seqcli.sln.DotSettings +++ b/seqcli.sln.DotSettings @@ -1,4 +1,5 @@  + True True True True diff --git a/src/SeqCli/Cli/Commands/QueryCommand.cs b/src/SeqCli/Cli/Commands/QueryCommand.cs index 9e9e986e..9630b421 100644 --- a/src/SeqCli/Cli/Commands/QueryCommand.cs +++ b/src/SeqCli/Cli/Commands/QueryCommand.cs @@ -55,7 +55,15 @@ protected override async Task Run() } var connection = _connectionFactory.Connect(_connection); + var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null; + if (timeout != null) + { + // The timeout is applied server-side; allowing an extra 10 seconds here means that the + // user experience will be consistent - the error message will be the server's message, etc. + connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10)); + } + if (_output.Json) { var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);