beast icon indicating copy to clipboard operation
beast copied to clipboard

websocket_client_async_ssl_system_executor sample exits before connecting

Open markus-bonk opened this issue 4 years ago • 10 comments

Boost 1.73 BOOST_BEAST_VERSION 290

Steps necessary to reproduce the problem

Compile and run the Debug x86 configuration in the attached sample with visual studio 2019. This is the same sample as in the boost/beast deployment. Debug x86 has the command line arguments inserted. websocket_client_async_ssl_system_executor.zip

The issue with the sample is the code line 258: net::system_executor().context().join();

Contrary to the comment in the code this does not wait until the system_executor runs out of work but actively invokes scheduler_.work_finished(); which decrements the outstanding_work_ count and stops the scheduler_, resulting in the websocket session ending prematurely.

As I am using the websocket_client_async_ssl_system_executor sample as the basis of my own work how one can wait on the system_executor?

Thanks Markus

markus-bonk avatar Jun 30 '20 15:06 markus-bonk

Thanks for the heads -up @markus-bonk .

Is there a particular reason you are looking to use the system_executor in preference to an io_context::executor_type?

I only ask because there are moves afoot to remove system_executor from net.ts, as it has some counter-intuitive behaviour traits that can catch out the unwary developer.

madmongo1 avatar Jun 30 '20 16:06 madmongo1

The main reason for going for the system_executor is/was that it hides the complete thread implementation/management: it looked like just a case of create the session, initiate it (three lines of code), then let the method do something else and come back later to see what was happening.

markus-bonk avatar Jul 01 '20 05:07 markus-bonk

This issue has been open for a while with no activity, has it been resolved?

stale[bot] avatar Aug 01 '20 09:08 stale[bot]

It looks like this issue has either been abandoned or resolved so I will go ahead and close it. Feel free to re-open this issue if you feel it needs attention, or open new issues as needed. Thanks!

stale[bot] avatar Aug 08 '20 09:08 stale[bot]

This issue has been open for a while with no activity, has it been resolved?

stale[bot] avatar Sep 07 '20 13:09 stale[bot]

@markus-bonk Can you try using the asio::thread_pool instead?

klemens-morgenstern avatar Sep 24 '22 05:09 klemens-morgenstern

I experience the same issue, but it presents only on Windows, not on Linux which is odd.

dasigvr avatar Feb 08 '23 11:02 dasigvr

I am ok with removing this example. The system executor is questionable.

vinniefalco avatar Feb 08 '23 14:02 vinniefalco

I like the ergonomics of system_executor since I don't have to pass it around like the io_context. However it's too buggy to be useful.

dasigvr avatar Feb 09 '23 09:02 dasigvr

Idiomatic ergonomics is to pass an Executor to constructors.

vinniefalco avatar Feb 09 '23 18:02 vinniefalco