Skip to content

Необходимо добавить в конфиг RequestTimeout для ElasticSearch #70

Description

@1rV1N-git

в конфиге есть "MaxRetryTimeout - таймаут попытки подключения"
но судя по коду это время ожидания между попытакими.

// If it's the same node then wait while MaxRetryTimeout occurs, otherwise it'll be a too often request's loop
if (_currentNode.Host.Equals(currentNodeHost))
    await Task.Delay(_maxRetryTimeout, cancellationToken);

А реальное назначение времени ожидания ответа от Elasticsearch настраивается через RequestTimeout который в дефолте 60 секунд.

Так как у меня эластик медлено отвечает пока добавил вот так в коде.

ElasticSearchStorage.cs

var settings = new ConnectionSettings(uri);
settings.EnableHttpCompression();
settings.MaximumRetries(_maximumRetries);
settings.MaxRetryTimeout(_maxRetryTimeout);
settings.RequestTimeout(TimeSpan.FromSeconds(1000));

P.S. у меня когда elastic не отвечал вовермя программы не выдавала ошибку просто тихо молчала( пришлось добавлять в код дополнительные логи что бы увидить ошибку

if (response.IsValid)
 {
     _logger?.LogDebug($"Get valid response {_eventLogItemsIndex} ");
     var item = response.Documents.FirstOrDefault();
     if (item is null)
     {
         _logger?.LogDebug($"Item is null");
         return null;
     }
     return new EventLogPosition(item.FileName, item.EndPosition, item.LgfEndPosition, item.Id);
 }
 else
 {
     var debugInfo = response.DebugInformation;
     _logger?.LogDebug($"Get invalid response {debugInfo}");
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions