redboltz / async_mqtt

Asynchronous MQTT communication library based on Boost.Asio
Boost Software License 1.0
91 stars 10 forks source link

Is there a way to get the error code if async_underlying_handshake fails due to server_unavailable? #323

Closed Meisterian closed 3 months ago

Meisterian commented 3 months ago

Hello,

I'm using mutual TLS and I am also verifying the host name with boost::asio::ssl::host_name_verification. With async_underlying_handshake; I get an error code if the host name verification fails, but the boost::asio::coroutine stops if for example the host name is not found. Is it possible to distinguish which sub layer that fails and why? It would be good for troubleshooting and logging.

Regards, Christian

redboltz commented 3 months ago

I am not sure what you exactlly mean. Do you get "Host not found" message? I guess so.

Do you want to more detailed error information ?

Which example are you talking about?

Anyway, error_category could help you. https://www.boost.org/doc/libs/1_85_0/libs/system/doc/html/system.html

For example:

(error_code ec) {
    std::cout << ec.category().name() << " " << ec.message() << std::endl;
}
Meisterian commented 3 months ago

Sorry, my fault! My unit test timeouts caused the problem. Increasing them fixed the problem.