Skip to content

Elasticsearch.Net Doesn't Time Out Async Calls (HttpWebRequest Usage Bug) #2438

@WarrenAlpert

Description

@WarrenAlpert

NEST/Elasticsearch.Net version: 2.4.7

Elasticsearch version: All Versions
Description of the problem including expected versus actual behavior:
Async requests don't respect RequestTimeout set in ConnectionSettings (including the 60 second default). My team recently ran into network issues, meaning these requests to the cluster weren't completing, and this bug in ES.Net exacerbated the issue by pooling up an ever growing number of connections until we couldn't handle any more.

I located the bug here:

var response = (HttpWebResponse)(await request.GetResponseAsync().ConfigureAwait(false));

As you can see on MSDN, HttpWebRequest.Timeout is NOT respected on async requests. Not sure the best solution, but one is to use HttpClient, which doesn't have this issue.

Steps to reproduce:

  1. Network issues or slow cluster response that causes a request to take longer than RequestTimeout in ConnectionSettings.
  2. The request does not time out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions