Skip to content

Conversation

@matwey
Copy link
Contributor

@matwey matwey commented Aug 19, 2024

Provide better implementation for Boost.ASIO library support. New implementation have the following advantages over existing one:

  • all OS supported
  • TLS/SSL is supported natively on all OS using Boost.ASIO
  • Boost.ASIO multithreading support is safe and correct (see examples/libboostasio_multithreading.cpp)

Provide better implementation for Boost.ASIO library support.
New implementation have the following advantages over existing one:
 * all OS supported
 * TLS/SSL is supported natively on all OS using Boost.ASIO
 * Boost.ASIO multithreading support is safe and correct (see
   examples/libboostasio_multithreading.cpp)
@corporategoth
Copy link

corporategoth commented Jul 22, 2025

FYI, I just tested this

You need to change line 120-122 from:

		for (const auto& buffer: _rx_streambuf.data()) {
			consumed_total += _connection.parse(reinterpret_cast<const char*>(buffer.data()), buffer.size());
		}

to:

		auto const_buffers = _rx_streambuf.data();
		for (const auto* buffer = boost::asio::buffer_sequence_begin(const_buffers);
				buffer != boost::asio::buffer_sequence_end(const_buffers); ++buffer) {
			consumed_total += _connection.parse(reinterpret_cast<const char*>(buffer->data()), buffer->size());
		}

The current code as written does not compile with at least boost 1.87.0

Otherwise, the minimal testing I've done seems to show this patch works, and allows me to connect with SSL appropriately, and even, because I am doing the connection myself, I can adjust certificate verification and support mTLS (which RabbitMQ supports).

@matwey could you update this as per the above, and @EmielBruijntjes , could we get this merged?
It breaks anyone currently using libboostasio.h - but this IS required to both better integrate boost::asio, and to ensure SSL works correctly without reported memory leaks, etc (see #424, #238, #207)

@matwey
Copy link
Contributor Author

matwey commented Jul 22, 2025

@corporategoth I need some time to return into the context. Don't expect me to reply soon.

@matwey
Copy link
Contributor Author

matwey commented Aug 29, 2025

Your code won't work as you expected:

		auto const_buffers = _rx_streambuf.data();
		for (const auto* buffer = boost::asio::buffer_sequence_begin(const_buffers);
				buffer != boost::asio::buffer_sequence_end(const_buffers); ++buffer) {
			consumed_total += _connection.parse(reinterpret_cast<const char*>(buffer->data()), buffer->size());
		}

The reason is that _connection.parse doesn't store or cache its input. So, if you would ever have real buffer sequence instead of single buffer one, then you needed to squash it before feeding into _connection.parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants