beast
beast copied to clipboard
How to upgrade a SSL based ASIO socket to Beast WebSocket?
Can you provide me an example code where the async SSL-based ASIO socket is moved to the beast socket to open up the websocket?
Sure, this is possible with latest asio as asio ssl streams became moveabke in boost 1.68
Any example code? I use boost 1.75. damn sure this is possible.
I can knock something up when I get home
Thank you so much:)
One thing I want to mention, I did the handshake using the Boost ASIO library and then moved the socket to Beast. After moving, I just have code to accept() and read() asynchronously.
seems like I am getting an uncaught exceptions when moving the socket:
`class webSocketConnection { public: using con_handle_t = std::list<std::shared_ptr<Connection>>::iterator; boost::beast::websocket::stream<boost::asio::ssl::streamboost::asio::ip::tcp::socket> web_socket;
webSocketConnection( con_handle_t con_handle,
boost::asio::ssl::context& ssl_context ) :
web_socket(std::move(con_handle->get()->ssl_socket.next_layer()), ssl_context) { web_socket.accept(); }
};`
Creating object:
capegen::webSocketConnection webSocketConnectionObj(con_handle, ssl_context);
seems like the boost ASIO handshake is not working if we open up a web socket connection from the browser...
OK. I am confused. I will just wait for your example program.
boost::beast::websocket::stream<boost::asio::ssl::streamboost::asio::ip::tcp::socket> web_socket;
Is the above code correct to define a web socket?
How do we move the SSL request and aync_accept on the Beast side?
Drilling down, I believe I face trouble in the moving request, accepting WebSocket connection.
Is this resolved?