beast: http client tcp ssl stream async_shutdown blocks forever

Our server calls into another 3rdparty https server as part of handling a http request , what we are seeing is that the client works fine and gets the response from the 3rd party server but async_shutdown blocks forever. The client is copied from the boost beast awaitable ssl async client example. The client blocks in the async_shutdown despite setting the timeout for the lowest layer.

As an extra step i tried setting the connection header to close so that the server would immediately close the connection. But there was no change in the behavior.

I am using boost 1.82. Please advise on what could be possibly going wrong. Thanks

beast::get_lowest_layer ( stream ).expires_after ( std::chrono::seconds ( 10 ) );
auto [ ec ] = co_await stream.async_shutdown ( net::as_tuple ( net::use_awaitable ) );  <--- blocks forever here

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

seeing the same thing here fwiw async_shutdown seems to hang forever if the client isn’t cooperative and beast::get_lowest_layer ( stream ).expires_after ( std::chrono::seconds ( 10 ) ); seems to have no effect either Reproducable for me on windows using openssl s_client -connect localhost:7000 as a client, have not tried a minimal example (sorry.)

Ended up just doing beast::get_lowest_layer(stream).close() as my use case does not care about graceful shutdowns

Try testing it in isolation; check whether async_shutdown in client_awaitable_ssl.cpp works correctly with your server or not.