319 questions
1
vote
1
answer
93
views
Monitor boost io_context availability
I want to set up a watchdog that checks whether the io_context workers can pick up tasks within a reasonable time and are not stuck running long or blocking operations.
To achieve this, I've ...
2
votes
1
answer
74
views
Boost.Beast async_connect fails after upgrading Boost 1.78 to 1.89
I have a Websocket class that connects asynchronously using Boost.Asio and Boost.Beast. The following code was working fine with Boost 1.78, but after updating to the latest Boost version, I now get a ...
2
votes
1
answer
169
views
How to parse multipart/form-data from http::request<http::string_body> object?
I am reading a http::request<http::string_body> request from the network using boost::beast, which is of type multipart/form-data. The request contains files and strings.
How can I get each part ...
3
votes
1
answer
101
views
Why prepare_payload removes Transfer-Encoding: chunked from http::response?
I create http::response<string_body> and call prepare_payload() after the response is built like this
http::response<http::string_body> res;
res.version(11);
res.result(http::status::ok);
...
3
votes
1
answer
99
views
Is it correct to reset the connection in websocket::stream_base::decorator callback?
I have a websocket server where I call websocket::stream::async_accept to perform a handshake with the client.
I also set a decorator to modify the headers like this
conn->get_websocket_stream()....
4
votes
1
answer
64
views
Does http::response_parser inherits limits from source parser?
I create http::response_parser<http::buffer_body> and set header_limit and body_limit like this
auto parser = std::make_shared<http::response_parser<http::buffer_body>>();
parser->...
2
votes
1
answer
109
views
call ssl::stream::async_shutdown after read operation cancelled
I have one active async operation, it is http::async_read. At the moment when I want to close the ssl connection, I cancel this async operation on the socket by calling ip::tcp::socket::cancel.
Then I ...
3
votes
1
answer
59
views
Correct way to convert http::response_parser<http::buffer_body> to http::response_parser<http::string_body>
I have a response parser of type http::response_parser<http::buffer_body>, which I need to convert to a parser of type http::response_parser<http::string_body>. I do the conversion after ...
2
votes
1
answer
119
views
Access the http response body before the entire response has been read
I need to read the response from an HTTP server like this:
first call boost::beast::http::async_read_header to get headers,
then read the response body (if any).
To read the body I use boost::beast::...
0
votes
0
answers
77
views
control_callback is not called after sending close frame
The documentation for websocket::stream::async_close says:
This function is used to asynchronously send a close frame, which
begins the websocket closing handshake. The session ends when both
ends of ...
2
votes
1
answer
80
views
Call async_ping and/or async_close when there is an incompleted async_write operation
The boost documentation has me confused.
The boost 1.68.0 documentation for websocket::stream::async_ping says:
This operation is implemented in terms of one or more calls to the
next layer's ...
3
votes
1
answer
160
views
Correct use of ping/async_ping with websockets
Let's say we have a websocket client based on boost::beast. At some point we want to send a ping frame to the server. To do this, boost::beast::websocket::stream offers two options:
Use the ping ...
3
votes
1
answer
152
views
Correct way to read & write data to boost::beast::websocket::stream
When we write data to plain socket or ssl::stream, it is recommended to use message queue to send data. In this case, I store messages in queue of type std::queue<std::string> and generally use ...
2
votes
1
answer
78
views
How to read and modify boost::beast::flat_buffer
I need to read data from boost::beast::flat_buffer into a std::string, then modify the string object and write the result back into boost::beast::flat_buffer.
To convert boost::beast::flat_buffer into ...
1
vote
1
answer
106
views
What exactly boost::beast::websocket::stream::set_option method does do
That's how documentation describes boost::beast::websocket::stream::set_option:
Set the permessage-deflate extension options.
https://live.boost.org/doc/libs/1_68_0/libs/beast/doc/html/beast/ref/...
1
vote
1
answer
124
views
websocket::stream::async_handshake with custom request
I am reading an HTTP request from the network that I want to use in a handshake with a remote websocket server. The websocket::stream::async_handshake API does not provide a way to specify the request ...
4
votes
1
answer
86
views
How to read trailer headers in boost::beast::http
As I understand it, in HTTP 1.1 in case the response comes in the form of Transfer-Encoding: chunked, the response may also contain trailers (additional headers) after the body.
I have two questions ...
4
votes
1
answer
111
views
Correct way to read HTTP responses without body
I have a program through which the user can send http requests. As you know, not every HTTP request assumes a response body. Responses to some requests may contain only headers (for example, a ...
2
votes
1
answer
104
views
Declaration of a variable without yet knowing the deduced return type that would otherwise be assinged via auto var =
Using Boost.Asio in C++23, how can I declare the below code's endpoints variable outside of the try-catch scope in which it is assigned a value? If it was declared inside the try, the assignment would ...
1
vote
1
answer
147
views
Correct way to access boost::beast::http::request object
I read http request using boost::beast like this:
// ...
auto buffer = std::make_shared<boost::beast::flat_buffer>();
auto request = std::make_shared<boost::beast::http::request<boost::...
0
votes
0
answers
53
views
secure boost::beast::websocket server with SSLKEYLOGFILE support
I have a secure websocket server written with Boost Beast using Boost-asio. A significant portion of the connection code is documented here. The server uses RSA keys for TLS encryption. I would like ...
2
votes
0
answers
55
views
boost beast secure websocket server - determine TLS version of incoming connection
I have a secure websocket server written with Boost Beast. A significant portion of the connection code is documented here. I need to extend the code to make a runtime decision on whether the incoming ...
1
vote
2
answers
90
views
Why can't the result of boost::beast::http::async_write with token as_tuple(deferred) be converted to awaitable<tuple<error_code, size_t>>?
Clang tells me there is no viable conversion from the return value of boost::beast::http::async_write with completion token boost::asio::as_tuple(boost::asio::deferred) to awaitable<tuple<boost::...
1
vote
0
answers
138
views
Segmentation Fault on Linux C++ Boost Asio Server build
Segmentation Fault in Boost Asio Server on Linux during flat_buffer::prepare() call
Problem Description:
I have a C++20 server application using Boost.Asio 1.85 that works perfectly on Windows but ...
0
votes
0
answers
38
views
Error in getUpdates request to a Telegram bot using boost beast
Trying to get updates from a telegram bot with a post request:
POST https://api.telegram.org/bot<token>/getUpdates
This works fine in Postman, I am getting the response from bot:
{
"ok&...
1
vote
1
answer
261
views
Boost.Beast WebSocket Server - "Read error: The I/O operation has been aborted" on Client Connection
I'm building a WebSocket server using Boost.Asio and Boost.Beast with SSL. The server accepts connections, but I'm encountering an issue where the client disconnects shortly after connecting. The ...
1
vote
1
answer
169
views
boost beast async stackless coroutine HTTPS client throws: 167772451 - application data after close notify (SSL routines)
I'm trying to develop a quick HTTPS client using boost::beast (version 1.86) and stackless coroutines. I'm throwing up an HTTPS post to api.mailgun.net.
Everything works EXCEPT RIGHT AFTER the ...
-1
votes
1
answer
165
views
Boost::Beast websocket client does not send Pong response
I'm developing a websocket clent listening for Binance market data stream to read a quotes. I'm using Boost::Beast websocket for this purpose. The connection uses SSL. My problem is that my client ...
2
votes
1
answer
63
views
boost beast async read argument overload or mismatching
AsyncReadStream& stream,
DynamicBuffer& buffer,
basic_parser< isRequest >& parser,
ReadHandler&& handler = net::default_completion_token_t< executor_type< ...
2
votes
1
answer
188
views
Handling multiple WebSocket write requests in a continuous loop with Boost.Beast
template<typename Derived>
class Websocket: public std::enable_shared_from_this<Websocket<Derived>>
{
public:
using InternalWSType = boost::beast::websocket::stream<
...
0
votes
0
answers
99
views
Boost Beast WebSocket server Opening and Closing connection does not deallocate all memory on heap
I have been working to understand a series of unexplained memory allocations that don’t make sense in the boost beast websocket framework. I have taken the example of the async server implementation ...
1
vote
1
answer
111
views
passed a socket to a method which is wrapped with shared ptr but beast tcp stream socket generate error stating that the socket is deleted
void connections::start_acceptor(){
auto socket=std::make_shared<boost::asio::ip::tcp::socket>(ioc);
con_acceptor.async_accept(*socket,[this,socket](const boost::system::error_code ec){...
2
votes
1
answer
641
views
Debugging a WebSocket Connection Through a Proxy Using Boost Asio and Beast in C++
I have written a script using Boost Asio and Boost Beast to enable WebSocket communication through a proxy server.
I managed to develop a working prototype following How to connect with boost::asio ...
3
votes
1
answer
100
views
Trying to Implement Idle Timeout by cancelling current async_read and continuing with next read/write operation
I am using a timer and an async_read, so whenever the timer runs out it cancels the async_read by doing ws_.next_layer().cancel() so that i can continue with my next operation. but when I catch the ...
0
votes
1
answer
178
views
boost::beast::websocket server doesn't react to client close()
I have a boost::beast HTTP server that streams data to a connected client. I'm happy to ignore anything they send to me, so I constantly call async_write without calling async_receive. But I think ...
2
votes
1
answer
103
views
When constructing a new std::thread, is there a point to wrapping the callable in std::bind?
I'm pretty unfamiliar with modern C++, but I've been looking at the Boost.Beast sample files and trying to understand how they work.
Specifically, I've been looking at this http server sample.
Here's ...
1
vote
0
answers
95
views
how to write and read at the same time in boost ssl web socket server?
Currently I'm using codes of this link text and in on_read I call a function which sends some string data multiple times in a loop, using ws_write(). The problem is that I can not read from the same ...
1
vote
1
answer
1k
views
Websocket boost/beast example with client/server
Maybe somebody can provide simple example(or references) on how to setup client and server using websocket from boost/beast library? I need an example on how to handle input message on server and ...
1
vote
1
answer
772
views
Clarification on Properly Shutting Down a Boost Beast Server
I'm working with the Boost Beast advanced server example (available at Boost.org) and am using it as a basis for my own server. My understanding is that in this example, both the session and the ...
0
votes
1
answer
154
views
Boost Beast 1.84 server example and clangd warning in QT Creator 13
When I load the following original boost beast 1.84.0 server example into my IDE QT Creator 13.0 (C++20), I get the following warning with clang-tools 17.0.1. How can I fix/work around this and is ...
0
votes
0
answers
79
views
Sending .gz file in HTTP GET RESPONSE
I am trying to write a Server code(Sender) to send a .gz(GZIP) file as part of HTTP GET response.
I need use C++ based solution for this. I am using below approach.
constexpr std::size_t chunk_size = ...
0
votes
1
answer
109
views
deducing this and std::bind
I'm getting errors when trying to pass a function using deducing-this to std::bind. See the example below.
#include <iostream>
#include <functional>
struct A {
void foo_deducing_this(...
1
vote
1
answer
228
views
Running boost beast resolver for multiple URLs in parallel
I was wondering that if we run multiple calls of async_resolve than in practice the io_context doesn't run more than one request at the time due to a known limitation.
Here's a sample example where I'...
1
vote
1
answer
99
views
C++ simple http server, the program closes on the second request and does not send the contents of the string
this is what my fileCollector looks like, it just stores a "cache" of files (so that you don't read the file during each request)
class FileCollector
{
public:
FileCollector()...
2
votes
1
answer
1k
views
Boost.Beast WebSocket with SSL: Multiple async_handshake calls needed for proper initialization?
I'm encountering an issue while trying to establish a WebSocket connection with SSL using Boost.Beast and Boost.Asio. The WebSocket connection seems to be working only when I call both async_handshake ...
2
votes
1
answer
464
views
Designing TCP to WebSocket
I'm planning to have TCP to WebSocket tunnel. Multiple TCP connections to one WebSocket connection(I know this require multiplexing but one thing at a time). This means having a TCP socket listening ...
0
votes
1
answer
50
views
Missing template arguments for Request in Boost.Beast
Representative code that I try it for http::request is
#include <boost/beast/http/message.hpp>
namespace http = beast::http;
using Request = http::request;
but for the last line I obtain &...
5
votes
0
answers
2k
views
boost::beast vs uwebsockets library performance c++
I'm porting a python application over to C++. As I'm not incredibly familiar with C++ I was wondering if there are any benchmark test result out there for websocket latency between the two libraries ...
-1
votes
1
answer
103
views
(process 7352) terminated with the code -1073741819
I am trying to make a REASON API server that will accept requests from another application, but the problem is that after the first connection to it, it shuts down with the error -1073741819. When I ...
2
votes
1
answer
579
views
When do I need to dispatch to strand with Boost Beast?
I have this code from Boost Beast async chat server examples:
void ChatServer::StartAccept() {
acceptor.async_accept(
boost::asio::make_strand(acceptor.get_executor()),
[self = ...