Skip to content

A connection to http://example.com/ was leaked. Did you forget to close a response body? #1

@ghost

Description

square/retrofit#1556.

square/okhttp#2217

I think a close needs to be done on the response body?

This is my net code.

        HttpResponseMessage response = null;
        try
        {
            using (response = await httpClient.PostAsync(requestUri, request).ConfigureAwait(false))
            {
                if (!response.IsSuccessStatusCode)
                {
                    var data = ToInsightsDataDictionary(requestUri.ToString(), json);
                    Insights.Report(new ServerException(response), data, Insights.Severity.Critical);
                }
            }
        }
        catch (Exception ex)
        {
            var data = ToInsightsDataDictionary(requestUri.ToString(), json);
            Insights.Report(ex, data, Insights.Severity.Critical);
            throw;
        }
        finally
        {
            response?.Dispose();
        }

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