boostorg / beast

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

Websocket example #2917

Open Dimitrius-dev opened 1 month ago

Dimitrius-dev commented 1 month ago

Hello, Boost=1.84.0, BOOST_BEAST_VERSION=351 I am using boost/beast websocket TLS async client example link. I noticed my connection disconnects sometimes with stream truncated and eof. What do these errors mean? I checked my internet connection with wireshark and it's fine.

ashtum commented 1 month ago

Do they happen at the end of stream? error::stream_truncated

Dimitrius-dev commented 1 month ago

No, i get these errors without calling any shutdown or disconnect function. And it shows when use client for high load traffic (high frequency).

ashtum commented 1 month ago

Are you sure it’s not the server that dropped the connection? Does this happen with just one specific server?

Dimitrius-dev commented 1 month ago

Can connection issues occur if multiply connections use load_certificates function?

ashtum commented 1 month ago

Do you mean load_root_certificates? it calls ssl::context::add_certificate_authority which is not thread safe.

Dimitrius-dev commented 1 month ago

I made n threads. Every thread has its own asio context, and interact with the same internet resource

ashtum commented 1 month ago

Do they have their own ssl::context too?

Dimitrius-dev commented 1 month ago

yes

ashtum commented 1 month ago

Have you tried reducing your application to a single connection and a single thread to see if the issue still exists? If possible, test one of the existing examples.