boostorg / beast

HTTP and WebSocket built on Boost.Asio in C++11
http://www.boost.org/libs/beast
Boost Software License 1.0
4.36k stars 634 forks source link

More complete SSL websocket example #2276

Closed gitgitwhat closed 8 months ago

gitgitwhat commented 3 years ago

I'm wondering if there are more complete examples available for SSL websockets besides just sending a single message and shutting down. For example, how do you keep the connection alive after the on_handshake? And does a message have to be sent at that time? I have a pretty typical websocket client use case but just having trouble with some of the boost::beast basics.

vinniefalco commented 3 years ago

Timeouts and keep-alives are not specific to SSL connections. Have you had a look at this? https://www.boost.org/doc/libs/1_76_0/libs/beast/doc/html/beast/using_websocket/timeouts.html

gitgitwhat commented 3 years ago

Thanks @vinniefalco I found your CppCon2018 talk and have been looking through that. It is helpful to understand how the server works but my client isn't a browser so still need to figure out how to extend the existing client examples to do a back and forth.

Unrelated, curious if you have ever done any performance and scaling tests on the various threading models. I've read about websocket servers written in Golang that can handle 1M+ concurrent connections on relatively modest hardware. I'd assume something written in C++ could do that just as easily.

madmongo1 commented 3 years ago

Beast/asio is limited only by the hardware and OS. I can confirm that massively scaling is possible with beast and works well. I did this when working for a cryptocurrency exchange.

gitgitwhat commented 3 years ago

Thanks @madmongo1 I assumed as much.

Can you share any write ups, code examples, or gotchas to achieve scale? It's a interesting problem that I'm just not that familiar with but want to learn.

madmongo1 commented 3 years ago

Late here now but I’ll write something in it after I’ve competed this months blog (which covers some epic new features about to be released in asio)

amanbadone commented 1 year ago

Hy, This issue seems interesting to me Although I currently don't have sufficient knowledge regarding the technicality I would still like to ask if I can give it a try to document it. This process will also let me learn the technical aspect and also about the contribution in this repo. Maybe you can give me instructions on what you want to get completed in the documentation