Richard Hodges

Results 201 comments of Richard Hodges

It may be that only one thread was performing a read, but if so, that thread has initiated a async_read without waiting for the first one to complete. This will...

A more common cause of this is initiating an async_write before a previous one has completed. Most full-duplex applications will require the use of a write queue in order to...

> > Really ?? The comment in the code says at any given time one async write and read can be happening. Are you telling me we can only have...

OK, so all async_reads and async_writes are: - being initiated on the same strand, and - making progress on that same strand ?

How are you initiating your async_write operations?

Here is an example of a correctly written full duplex websocket connection. https://github.com/test-scenarios/boost_beast_websocket_echo/blob/9eab1f8a2454c670b8830de704718ba6a2f567c0/pre-cxx20/echo_server/connection.cpp#L123 Note that every message to be written is : - marshalled onto the correct strand (the one...

From what you have described to me, you are initiating reads and writes on the websocket from random threads. This will result in UB. If you follow my example you...

Does any of your code look like this? ``` void connection_impl::send(std::string msg) { net::dispatch(net::bind_executor( stream_.get_executor(), [self = shared_from_this(), msg = std::move(msg)]() mutable { self->handle_send(std::move(msg)); })); } ```

in this function, regardless of which thread or executor it's called from, the actual work is transferred to the strand with which the websocket stream was associated at construction time....

It sounds like you need to do some background reading of the ASIO documentation. `dispatch(e, f)` does this: ``` if(i am running on e already) f(); else post(e, f); ```