Skip to content

Cannot access a disposed object. 'System.Net.Http.StreamContent'. #259

Description

@mcphelan

Randomly getting object disposed error messages.
Cannot access a disposed object. 'System.Net.Http.StreamContent'.

Seen it when connecting

ApiSessionCreate apiSession = new ApiSessionCreate();
var response = await Client.Execute(apiSession).ConfigureAwait(false);

also when posting Bills

var requestConfig = new RequestConfig();
requestConfig.ControlId = batchId;

var response = await Client.ExecuteBatch(bill.Functions, requestConfig).ConfigureAwait(false);

Using a LoggingHandler to log reqeuest and response XML - in the latest scenarion I can see it has logged a Request but not the repsonse.

Could there be an issue in the SendAsync or MessageFormatter.Format ?

wondering in the LoggingHandler.SendAsync would it be better to load the Response content once

var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

and then pass into the MessageFormatter.Format as a parameter

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