Questions tagged [boost-beast]

1

votes
1

answer
43

Views

Multiple subscriptions with different subscription rate design through boost::beast

I am trying to design a system where I am creating a tree like structure and users can subscribe to any branch of the tree. Ex: If a tree looks like A--B--C | D Here A is the parent of B and B is the parent of C and D Now, a user places a subscription request of 5 seconds on the branch A-B-D. A 5 se...
Shubhi Agarwal
1

votes
2

answer
262

Views

Boost::Beast Non Blocking Read for Websockets?

We have an app that is entirely synchronous, and will always be because it is basically a command line interpreter to send low level commands to our hardware, and you cant have two commands going to the hardware at the same time. I will only ever have 1 client socket for this configuration operating...
user1024792
1

votes
0

answer
114

Views

Boost.Beast C4702 “unreachable” compiler warning on MSVC++ build

Building with Boost-1.67.0 and VS on Windows, I get a C4702 'unreachable' warning for boost::beast::http::detail::verb_to_string(verb v), in boost/beast/http/impl/verb.ipp: template inline string_view verb_to_string(verb v) { switch(v) { case verb::delete_: return 'DELETE'; case verb::get:...
badfd
1

votes
1

answer
163

Views

Angular5 + SocketIO to Boost::Beast

So i am using the tutorial here to setup my socket.io connection using Angular 5.x https://blog.codewithdan.com/2017/11/07/pushing-real-time-data-to-an-angular-service-using-web-sockets/ There are two scenarios happening and im not sure why one is working and one isnt, so im hoping someone can assis...
user1024792
1

votes
1

answer
308

Views

How to use boost::http::response_parser for parsing string?

I wanted to parse my own data using response_parser of boost::http. All the documentation I found is linked with http::request of boost. I have written my own SSLLink to get data. I want to feed the data incrementally to response_parser and check if a complete message has been parsed. I found this a...
bonacci
1

votes
1

answer
41

Views

HTTP Header Field not recognised

I'm trying to make use of boost::beast in order to communicate over HTTP with a server. I'm working on the Clientside and want to send a Request containing at least the following Header field: 'X-API-SIGNATURE'. I'm creating the Request as follows: http::request request; request.version(11); request...
Kaot
1

votes
1

answer
142

Views

Cmake ignores all my directives on where to find boost in boost::beast repository

I'm using Ubuntu 16.04 (with boost 1.58), and I have to develop a project with boost::beast. so I got the latest version of boost (1.67), and now I'm trying to compile the beast repository to play with the examples. I compiled boost in the simplest way possible. I did ./bootstrap then ./bjam, and it...
1

votes
0

answer
68

Views

Streaming some data from PHP to C++

My goal is to send, from a C++ app, a simple GET query to PHP, such as 'do re mi fa sol' and get some data I can play. The PHP script will return a stream of bytes that I will interpret in the C++ client. I read one byte to know the nature of the next segment (text or WAV audio file). I read 2 bytes...
Horsetopus
1

votes
1

answer
44

Views

What is the best way to decode Ntrip 1.0 protocal using boost::beast

I am currently using boost::beast to implement a ntrip 1.0 client. It has the request like: GET /BUCU1 HTTP/1.0 User-Agent: NTRIP GNSSInternetRadio/1.2.0 Authorization: Basic aHVnb2JlbjpodWdvYmVuMTIz And the response like: ICY 200 OK It has the non-standard http response. I as the beast http client...
Tao Li
1

votes
1

answer
95

Views

about boost beast websocket api : async_close, async_write

I have read the official document.I'm confused that the document conflict itself. Here is the document picked from the official: However, this code is well-formed: ws.async_read(b, [](error_code, std::size_t){}); ws.async_write(b.data(), [](error_code, std::size_t){}); ws.async_ping({}, {}); ws.asyn...
user9928049
1

votes
1

answer
297

Views

Boost Beast reconnect websocket connection after close

I am using boost::beast to create a websocket connection and so far it seems to work fine. But I am unable to figure out if i should replace the websocket::stream variable after disconnect. i.e. I have a variable: boost::beast::websocket::stream _ws After an async disconnect is initiated and comple...
john_zac
1

votes
0

answer
77

Views

boost::beast ws_.async_handshake breaks when synchorneous function works

I've built an app that connects to bitmex through boost::beast. The synchronous call works fine using the code provided at: https://www.boost.org/doc/libs/develop/libs/beast/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp however the code that does the same thing asynchronously at:...
user10055921
1

votes
1

answer
356

Views

Error reconnecting boost beast (asio) websocket and http connection after disconnect

I am creating a client application that connects to a server using a an ssl Websocket connection and an ssl Http (Keep-Alive) connection and I am using boost::beast package to do the same. So as to detect a dead connection i have implemented a simple ping-pong mechanism. These all work fine, but an...
john_zac
1

votes
1

answer
32

Views

“Body requirements not met” when passing a req to a method in c++ (Boost Beast library)

I am trying to pass a req to a method. My code is: void handle_request(boost::beast::string_view doc_root, http::request req, Send send) { some code here } but when I try to compile it, I am getting this error: 'Body requirements not met' How can I fix it? The error doesn't come from these lines, bu...
mans
2

votes
2

answer
195

Views

Boost Beast Async Server Failing with Assertion failed: (id_ != T::id) on multiple aync calls

Assertion failed: (id_ != T::id), function try_lock, file /usr/local/include/boost/beast/websocket/detail/stream_base.hpp, line 91. // Echoes back all received WebSocket messages class session : public std::enable_shared_from_this { websocket::stream ws_; boost::asio::strand< boost::asio::io_context...
VikramChopde
1

votes
1

answer
94

Views

Undefined symbol boost::system:detail::system_category_instance

I've build boost with c++17 standard with clang on macOS Mojave when compiling my playground program that uses beast and asio I get the following error: This is my make file: cmake_minimum_required (VERSION 3.13.1) project (Playground) set(Boost_USE_STATIC_LIBS ON) set(Boost_USER_MULITHREADED ON)...
Fabian
1

votes
0

answer
165

Views

C++ Boost Beast empty response body

I'm playing around with the Beast part of Boost and I'm trying to create a simple http client that can be used to /GET the content form a web resource (simple HTML or REST services). I've used the example that can be found in github repo of beast for a sync http client and moved it to a simple class...
Fabian
1

votes
1

answer
59

Views

Beast websocket idiomatic shutdown?

I have my C++ program. The main thread creates a new thread that is dedicated to only handling a websocket. This new thread reads and writes using for example boost beast's async_read() calls. It is much like https://www.boost.org/doc/libs/1_69_0/libs/beast/example/websocket/server/async/websocket_s...
user782220
1

votes
1

answer
60

Views

boost beast async_write increases memory footprint dramatically

I am currently experimenting with the boost beast library and now very surprised by it's memory footprint. I've found out by using three different response types (string, file, dynamic) the program size grows up to 6Mb. To get closer to the cause, I took the small server example from the library and...
Mohamed El
1

votes
1

answer
31

Views

How do I pass the model type in boost beast websocket

I am working with c++11, beast library and IBM speech to text web service. The websocket interface (to connect) needs the authentication token as request header while the handshake is performed. Refering to this code available in the Watson documents it looks like I have to pass the model type (if I...
RC0993
1

votes
1

answer
58

Views

How can I convert serialized data in boost::beast to a string so that I could process it in a FIFO manner?

I have an application of a client where I need to receive http 'long running requests' from a server. I send a command, and after getting the header of the response, I have to just receive json data separated by \r\n until the connection is terminated. I managed to adapt boost beast client example t...
1

votes
0

answer
38

Views

Is it possible to handle a blocking read function with timeout?

I am working on boost websockets for asynchronous communication between the client and server. Now I am printing the time elapsed during the program with boost::timer::auto_cpu_timer. It is displaying the time elapsed in seconds. My program snippet is given below: This function sends the data to the...
RC0993
1

votes
1

answer
107

Views

What are the requirements to read and write from an http stream (in boost::beast)?

I would like to use boost::beast to read and write to etcd. For starts, I'd like to be able to do these examples with boost beast. They're easily doable with curl. Etcd can be seen as a key/value store. The functions to set/get (put/range in the examples page) are easy to do with the boost::beast cl...
1

votes
1

answer
273

Views

OAuth2 with beast boost returns temporary redirect 307

I'm trying to implement an app with access to google drive in beast boost C++ usingoauth2 authentication. https://developers.google.com/identity/protocols/OAuth2ForDevices I try to get the user code in Postman with the following POST request: POST /o/oauth2/device/code HTTP/1.1 Host: accounts.google...
user2828781
1

votes
1

answer
230

Views

boost beast WebSocket upgrade handshake failed

Using the example code of boost::beast(https://www.boost.org/doc/libs/1_66_0/libs/beast/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp), I got: Error: WebSocket upgrade handshake failed To make sure the server is ok, i created a test using https://www.websocket.org/echo.html, and it...
定坤宋
1

votes
1

answer
377

Views

boost-beast websocket server that also accept http connections

I need to implement a simple asynchronous websocket server using boost beast that can accept both websocket and standard http connections. I've tried something like this: ... // ws is a boost::beast::websocket::stream ws.async_accept_ex( [](boost::beast::websocket::response_type& res) { res.set(boos...
1

votes
2

answer
78

Views

Why does Boost Variant use the template constructor instead of the move constructor for boost::beast::websocket::stream?

I am trying to wrap boost::beast::websocket::stream (for 2 specific T) in a boost::variant to allow treating TLS ([T = boost::asio::ssl::stream]) and non-TLS ([T = boost::asio::ip::tcp::socket]) websockets the same. I am stuck at a compilation failure. The simplest failing example that I can come up...
Chris Hunt
1

votes
2

answer
225

Views

Boost Asio and Beast mulitpart/form-data save binary from streambuf

My results look like... POST /post HTTP/1.1 Host: localhost:3003 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://localhost:3003/profile Content-type: multipart/form...
forresttales
1

votes
1

answer
0

Views

How to read the header of a bad request in beast::websocket?

I have a websocket server(listening the loopback interface) that should respond to a GET request. Here's how I do that ws_.async_accept_ex( [self = shared_from_this()](websocket::response_type& res) // { if (res.result_int() == 400) { // bad request, assume HTTP GET osstream response; /* invoke requ...
Johnny
1

votes
1

answer
0

Views

Watson Text-to-Speech via C++ Boost Websockets - “No such host is known”

I've been unable to connect to Watson's Text-To-Speech service via websockets in C++ using the Boost Beast library I've got code that successfully interfaces with echo.websocket.org on port 80, but it does not work with Watson's url. I've tried using variants of protocols (http(s), ws(s), and unspec...
user2855323
1

votes
1

answer
0

Views

Boost beast manupulate http response headers durring accept

I would like to manipulate the http response sent to the websocket client durring accept. I've read the examples and the manual, I can pare the request, check if it's a websocket upgrade request, but I can't manipulate the response. It would be nice to have the websocket library to prepare the respo...
E.T.
1

votes
1

answer
59

Views

Can't do https-request with boost beast

Im using mingw64. How can I make https-request using boost beast lib? I got code below and it works, but I recieve answer: '400 The plain HTTP request was sent to HTTPS port' What should I complete here to make https request? OpenSSL is installed. #include #include #include #include #include #i...
Eugene
1

votes
2

answer
203

Views

Boost beast compilation error

d:\boost\boost\beast\core\detail\ostream.hpp(263): error C2955: 'boost::beast::detail::ostream_helper': use of class template requires template argument list When compiling example project: http_server_small.cpp (from 'beast') boost\beast\core\detail\ostream.hpp: template ostream_helper:: ostream_he...
Yuri Yaryshev
1

votes
1

answer
81

Views

bad_weak_ptr while using class inheriting from boost::asio::io_context::service

I started to practice using boost asio & boost beast to develop my own basic server and connection class. Recently I've encountered bad_weak_ptr exception and I can't figure out how to manage the problem. Here is the code: class server : public boost::asio::io_context::service { tcp::endpoint endpoi...
0x07
1

votes
1

answer
41

Views

using different request parser depending on the queried route

I'm Implementing a mini http server using boost beast. the server has two different routes POST /upload/... and the other one is POST /info. The first one is used for uploading some big files and the other one is for hadling json objects. To keep the performance as hight as possible am I trying to...
Mohamed El
1

votes
1

answer
35

Views

Store a STL map into a Boost ConstBufferSequence

I'm trying to store a std::map in a boost::beast::multi_buffer. So far I've been using boost::asio::buffer_copy and boost::asio::buffer to store vectors and PODs. However, I couldn't find a way to store a STL map. I've tried this: auto t_map = std::map(); // CODES is an enum type auto t_map_size = t...
Shmwel
1

votes
3

answer
57

Views

Using Boost::Beast for CPU-heavy REST APIs, Should I use Async or Sync way to implement them to expect the better latency?

I'm trying to use boost::beast to implement a web service providing some REST APIs. These APIs are CPU-heavy, almost no disk or db I/O. My goal is to optimize for latency with OK throughput. Should I use sync or async way to implement them? Thanks!
NonStatic
1

votes
2

answer
41

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
92

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

View additional questions