Skip to content

Exception from handle_write_large_body  #19

Closed
@ras0219-msft

Description

@ras0219-msft

Migrated from Codeplex: https://casablanca.codeplex.com/discussions/647518

niamurph wrote:

I am using cpprestsdk 2.6 and getting an exception with the description "Unexpected end of request body stream encountered before Content-Length satisfied.". It is thrown from the function handle_write_large_body. My suspicion is that there may be a concurrency issue in the web::http::client::http_client ( or maybe I am using it wrong).

Hitting the exception means that my request never gets sent.

I am running on Mac OS X 10.10.
By adding some logging statements I can see a buffer (boost::asio::buffer) of 90 bytes being written and then read. Usually a single read and a single write. But occasionally there is a second read, and since the buffer is already read, it retuns 0 leading to the path that hits the exception. The exception message says the size is wrong, but I think some concurrency issue has led to the buffer being read one more time after it has already finished.

I think it may be a concurrency issue, since I can avoid it by using a new connection for every message I send. If I reuse a web::http::client::http_client for multiple messages to the same server, then I hit this issue. Maybe I need to check that there are no messages still being processed for the http_client before I queue up another message to the same client, but I do not know how to do that.

Are there any known issues like this. My workaround for the moment is to create a new web::http::client::http_client for every message. That is probably not as good for performance. I can live with the workaround, but I would be keen to find the root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions