34 questions
-6
votes
1
answer
85
views
Cannot include Beast library in C++ [closed]
I want to use websockets in a c++ project. For this I am using boost library. I ma currently unable to import the library. I have added the path in environment variable
if i try to run the code this ...
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 ...
0
votes
0
answers
592
views
Is it possible to connect a c++ boost beast/asio websocket to a socket.io server in nodejs?
I've been struggling to get a basic application going where I use boost to attempt to connect to a local webserver hosted on nodejs using express and socket.io. the idea is to host a socket server and ...
0
votes
0
answers
315
views
C++ boost beast websocket crash after running a while
I am using boost beast to connect to a server's websocket.
I only rewrite the on_read function in order to make the websocket never disconnect, the other parts are just copied from beast example code.
...
0
votes
1
answer
2k
views
How to handle ping request on client (boost::beast::websocket)
Imagine that you have some websocket client, that downloading some data in loop like this:
#include <boost/asio.hpp>
#include <boost/beast.hpp>
#include "nlohmann/json.hpp"
...
1
vote
1
answer
175
views
Parsing json inside lambda function passed as handler function in async_read is causing json parsing error
#define BINANCE_HANDLER(f) beast::bind_front_handler(&binanceWS<A>::f, this->shared_from_this())
template <typename A>
class binanceWS : public std::enable_shared_from_this<...
2
votes
1
answer
595
views
Should I clean up beast::flat_buffer when I see errors on on_read?
http_client_async_ssl
class session : public std::enable_shared_from_this<session>
{
...
beast::flat_buffer buffer_; // (Must persist between reads)
http::response<http::...
0
votes
1
answer
251
views
Reacting to each tick events from the websocket
I would like to design my trading system reacting to each tick events from the websocket stream i subscribed to.
So basically i have two options :
void WebsocketClient::on_write(beast::error_code ec,
...
2
votes
1
answer
275
views
How to get request path in beast::websocket
I have the following beast::websocket example working: https://www.boost.org/doc/libs/1_76_0/libs/beast/example/websocket/server/async/
Starting from that code, and assuming that I want to distinguish ...
1
vote
1
answer
323
views
reduce response time while using async cpp boost socket
i've created an async beast server that gets a request from a browser, opens a second socket , writes the request , gets the response and sends it back to the browser. all async . as the "send ...
1
vote
1
answer
527
views
How to find if the 'target' for websocket::stream::async_handshake() is not found?
For HTTP calls, you can do:
http::async_read(m_stream, m_buffer, m_res, beast::bind_front_handler(&RestSession::on_read, shared_from_this()));
// ... then
void on_read(beast::error_code ec, std::...
3
votes
0
answers
500
views
Using boost::beast::websocket to send http post request
I've got the following class member
boost::beast::websocket::stream<boost::beast::tcp_stream> ws_;
which gets instantiated on class c'tor using boost::asio::io_service as parameter.
I assume ...
2
votes
1
answer
564
views
Is there any way to subscribe and to listen feed in boost beast websocket?
I am using an example from boost beast documentation for async websocket client. The to send some command to subscribe and then to listen feed until it is terminated manually (preferably with other ...
0
votes
1
answer
754
views
How to use boost::beast to connect to Coinbase's websocket API
I'm a bit new to websocket programming. I've been trying to use this example :- https://www.boost.org/doc/libs/develop/libs/beast/example/websocket/client/async-ssl/websocket_client_async_ssl.cpp to ...
0
votes
1
answer
384
views
Measuring client back-up when using Boost.Beast WebSocket
I am reading from a Boost.Beast WebSocket. When my application gets backed up, the websocket sender appears happy to delay/buffer the data on their end (presumably at the application level, as they ...
0
votes
2
answers
1k
views
Get IP of Websocket on known port
I have built a websocket in C++ (using boost::beast).
It is going to serve a website (client) with a JSON string if requested.
When designing my setup I made a disastrous mistake: I forgot that the ...
0
votes
1
answer
1k
views
boost websocket and io_context reusability for reestablishability of a connection
I have writted a small websocket client using boost::beast::websocket and boost::asio::io_context in C++. I am having a state machine with following states:
enum class State {
GDR_PROVISING,
...
1
vote
0
answers
396
views
Implement publish/subscribe with Boost Beast
I have a Websocket server based on Boost Beast and I want to implement a publish / subscribe pattern. My current code base is based on the advanced/flex example.
Is there a recipe / pattern on how to ...
0
votes
0
answers
215
views
How to use boost websocket to implement sub-protocol
I want to implement a websocket sub-protocol.
For example, I have a weboscket server as ws://localhost:1234, now I need one more sub-protocol as ws://localhost:1234/sub.
I know lib-websockets ...
1
vote
1
answer
2k
views
How to resolve could not decode a text frame as UTF 8 though boost websocket
I write a websocket though boost, and I receive the message though the client in chrome.
When I use ws, it works well, I can receive correct msg.
but when I use wss, it works bad, and said could not ...
-1
votes
1
answer
2k
views
How to use boost::aio::async_connect with lambda
I want to reliaze how to use boost::aio::async_connect with lambda.
Boost version 1.68
It's really strange that I could use std::bind but not lambda.
If I use std::bind, it work.
But when I use ...
1
vote
2
answers
735
views
How to set subprotocol with boost weboscket
I want to use the subprotocol with boost websocket.
For example, I have s websocket server address , ws://127.0.0.1:5005.
Now I want to replace it with ws://127.0.0.1:5005/order.
"order" is the ...
1
vote
1
answer
854
views
Boost Async Websocket Server Issue
I've wrote an async websocket thru boost.beast. But when I try to run it, I cannot connect it.
The server code like below. When I try to connect my websocket server, my chrome shows status connecting....
4
votes
1
answer
6k
views
Boost-beast websocket handshake problems
I am attempting to set up a websocket connection with a remote server and get the following error:
The WebSocket handshake was declined by the remote peer
I am following this example: https://www....
1
vote
1
answer
615
views
Boost beast manipulate 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 ...
1
vote
1
answer
255
views
Store a STL map into a Boost ConstBufferSequence
I'm trying to store a std::map<enum, int> 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 ...
1
vote
2
answers
161
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 ...
1
vote
1
answer
1k
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&...
0
votes
1
answer
1k
views
how to avoid callback hell with boost::beast?
I'm working on an application in which I want to use boost::beast/asio. I need to receive data via a websocket connection and issue requests to a REST API at the same time.
In the boost::beast ...
1
vote
1
answer
2k
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::...
4
votes
1
answer
4k
views
How to access Beast on Boost 1.66 and 1.67 from CMake
I'm trying to make a CMake project with Beast, and it's properly installed from source in /usr/local/include/boost, but I can't get CMake to find it. I though it might have been a 3.10.2, so I tired 3....
2
votes
1
answer
2k
views
How to pass read handler to async_read for Beast websocket?
How do I pass in a callback to async_read? I tried the following but it won't
compile. I based this off of modifying code from the docs
#include <beast/core.hpp>
#include <beast/http.hpp>
...
3
votes
2
answers
2k
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 (...
2
votes
2
answers
7k
views
How to do async read/write with Beast websockets
How can I do async write and read using websockets from the Beast library? I have tried to adapted the synchronous write/read example provided in the Beast documentation here, but the code below does ...