Questions tagged [boost-beast]

0

votes
1

answer
21

Views

Call a boost function without callback

I am using boost-beast library for a websocket connection. You can refer to this example for the understanding what is happening. I have used the same example, but changed a few things: split the on_handshake(beast::error_code ec) into three functions A(beast::error_code ec),B(beast::error_code ec)...
RC0993
1

votes
1

answer
84

Views

bad_weak_ptr with boost smart pointer

I develop a desktop chat with boost asio and beast (for browser support). I use this architecture : But, when building, I have an issue : bad_weak_ptr, I don't know what is wrong :s Here a link to the source https://onlinegdb.com/BkFhDGHe4 Update1 : I remove run() function into constructor and move...
Vana
2

votes
1

answer
451

Views

boost beast message with body_limit

My starting point is to create a simple downloader code from the boost beast http_client_async example at boost http_client_async. In this scenario i want to write the received body into a file. So I exchanged the string body into a file_body, to write the received data: http::response_parser res_;...
Tom
3

votes
2

answer
276

Views

how to use boost::asio::defer() in composing function?

On Boost 1.66, Asio have deprecated the asio_handler_is_continuation hook function, promoting usage of defer function. It seems that defer function is behaving exactly the same as post when asio_handler_is_continuation==true. However, the way of using defer is different from the way of using asio_ha...
he rambled
2

votes
1

answer
915

Views

Boost Beast HTTP

I am working on a http parser, and it looks like boost.beast is a nice one. However, I still have some questions: *** Assume HTTP Request POST data already received via boost.asio socket. Stored inside a std::string buffer. Is there any good sample on how to extract http header fields and its value...
Jimmy
7

votes
2

answer
3.2k

Views

C++ Send data in body with Boost.asio and Beast library

I've to use a C++ library for sending data to a REST-Webservice of our company. I start with Boost and Beast and with the example given here under Code::Blocks in a Ubuntu 16.04 enviroment. The documentation doesn't helped me in following problem: My code is, more or less, equal to the example and I...
Banzai
3

votes
0

answer
85

Views

Why is noexcept not used in async libraries (like Asio and Beast)

Asynchronous functions often do not use exceptions. Even on synchronous calls, Asio and Boost-Beast have overloads that take an output argument of type system_error& instead of throwing. Asynchronous operations can't throw exceptions because the operation doesn't complete in the stack frame of the c...
Benjamin Buch
3

votes
1

answer
193

Views

Boost::beast: Multiple async_write calls are firing an assertion error

I'm writing tests for my full-duplex server, and when I do multiple (sequential) async_write calls (although covered with a strand), I get the following assertion error from boost::beast in the file boost/beast/websocket/detail/stream_base.hpp: // If this assert goes off it means you are attempting...
3

votes
1

answer
515

Views

C++ Boost 1.66 using Beast http request Parser for parsing an string

I'm not using beast http server in my project but I was searching for a solution to parse an http request in form of std::string in my program ,is it possible to use boost/beast/http/parser.hpp in this case and if so it would be Great if you give an example in code. Thanks aloot
Amir Rasti
5

votes
1

answer
1.5k

Views

How to convert boost beast multi_buffer to string?

I copy websocket example from boost::beast website and run it Websocket session work fine but I don't know how to convert received multi_buffer to string. below code is websocket session handler. void do_session(tcp::socket &socket) { try { // Construct the stream by moving in the socket websocket::...
MohsenTi
2

votes
1

answer
318

Views

SSL tunnel with Boost::Beast

I want to connect to a proxy server that only allows HTTP connections, to speak with the target server by HTTPS. The proxy server documentation states that the only way to do that is by means of the HTTP Connect verb (they are planning to add direct HTTPS connections to the proxy server itself, but...
Peregring-lk
2

votes
1

answer
574

Views

Asynchronous processing of streaming HTTP with boost::beast

I'm implementing a client which accesses a REST endpoint and then begins processing an SSE stream and monitoring events as they occur. To this end, I'm using Boost::Beast version 124 with Boost 1.63 and attempting to use async_read_some to incrementally read the body of the response. Here's my code...
Tim Clemons
2

votes
1

answer
1.2k

Views

Using Boost-Beast (Asio) http client with SSL (HTTPS)

I am new to SSL and the Boost-Beast library, and also C++, but that's a different story. I have a question regarding using HTTPS (SSL) with Beast. I am going to use the library to connect to a REST service and post JSON to a server where I do not control the certificates, the API etc. And it kind...
user3259898
2

votes
1

answer
221

Views

boost beast memory usage for bulk requests

I run this boost-beast-client-async-ssl example and it's OK. But, if I create 10000 sessions at same time, my program memory usage grows up to 400 MB and never down. I'd test without ssl (simple http), and there wasn't grows up memory. Q: What's wrong with openssl ? There is my main function. //...
4

votes
1

answer
403

Views

Problems making a sync http request through proxy using Boost Beast

I've modified the http_sync example to connect through a proxy, I've tested with wireshark and the problem is that after I send the http connect request, the proxy returns with the code 200 OK, and my program cant read that, it gets stuck waiting on the http::read for about 1 minute and then the ser...
Petar Stankovic
2

votes
1

answer
155

Views

How to detect disconnection in websockt by using boost::beast?

I know I can use the error code in async_write, async_read to check the disconnection. However, in my situation, after I receiving something, I cannot write back immediately (or write back may never happens). During the time between reading and writing, how can I check the client disconnetion except...
Robin Lew
2

votes
1

answer
55

Views

Does websocket guarantee the completeness of a single message? Should I implement my own header for websocket messages?

I'm writing a backend for a web-application in C++ (with boost-beast), and the front-end will probably use socket.io. So this question applies to both implementation and whether there's something in the websocket standard that answers my question. I'm not sure what precautions to take to guarantee t...
3

votes
1

answer
1.3k

Views

How to redirect from HTTP to HTTPS with Beast C++ library?

I am studying the Boost.Beast library. I try to make a request whose response is: HTTP/1.1 301 Moved Permanently Cache-Control: public Content-Type: text/html; charset=UTF-8 Location: https://www.example.com/target/xxx/ Then, I try to make a request with this location field but I receive the bad req...
Juan Solo
3

votes
2

answer
493

Views

How to do async read/write Beast websockets alongside read/write of files?

I have my C++ program that forks into two processes, 1 (the original) and 2 (the forked process). In the forked process (2), it execs program A that does a lot of computation. The original process (1) communicates with that program A through standard input and output redirected to pipes. I am trying...
user782220
2

votes
1

answer
288

Views

Boost Beast: how to produce non-chunked response with a custom body when a content length is not readily available?

I am trying to implement a custom body type that would hold a parsed JSON tree object. The task seems pretty natural, but I can't find a way to generate non-chunked HTTP messages carrying JSON using Beast. I have a REST client/server implemented by wrapping libmicrohttpd and libcurl, but I would pre...
Vlad.Z
2

votes
0

answer
142

Views

boost::beast websocket asynchronous reading and writing connection lost

I am trying to read the RocketChat websocket API using boost::beast. It works when I read it using the synchronous examples, but when using the async_* functions somehow it appears the connection is closed. The offending code in question: #include #include #include #include #include class conne...
Martijn Otto
2

votes
1

answer
873

Views

How can i make Boost Beast Reply From A String Instead Of A File

I am trying to work with this example code boost beast advanced server example It compiles and works nice. Now i want to make it read from a given string to reply a Get or Post request instead of reading from a file. For example: Client sends a Get request for "www.xxxxxxxxxx.com/index.html" Program...
gokaysatir
3

votes
2

answer
423

Views

Boost Beast 1 second delay in server response

I am trying to create an HTTP server using boost::beast but I noticed a delay of one second in response time. I used the advanced server example and synchronous client example to benchmark this behavior. Also tried to disable Nagle's algorithm but had no effect and doesn't seem to be an optimisation...
Laur P.