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

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

Open
1rV1N-git opened this issue Feb 19, 2024 · 0 comments

Comments

@1rV1N-git
Copy link

1rV1N-git commented Feb 19, 2024

в конфиге есть "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}");
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant