You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of the development of the communicator component of the new agent, we chose to use boost asio/beast as our networking library, which also works with C++20 coroutines.
The first implementation is missing to check for many network errors that can occur during communication. Currently, any failure is not reported correctly and no recovery attempt is made, so we need to improve error handling.
Tasks to be done:
Ensure that all functions that use the Boost networking library are within the HTTPClient class.
Identify functions within the HTTPClient class that do not have error handling.
Apply changes to improve error handling.
Ensure that components that use the HTTPClient class (i.e. Communicator) are properly handling network errors/exceptions.
Errors reported during testing
When performing manual tests for other developments we have already encountered some cases that we have to solve:
if (const auto decoded = jwt::decode<jwt::traits::nlohmann_json>(*m_token); decoded.has_payload_claim("exp"))
a case occurred where a token was returned with an invalid jwt format and the co-routine that handled this task crashed, causing no further attempt to obtain the token and no errors were logged.
if the json object has a different format than expected causing “token” to not be where you are looking for it, it causes the crash when trying to do the get_ref() since the at() above would fail.
2024/11/28:
Reviewing the code. Looks like some of the errors are already fixed. Investigating how to deal with boost::asio timeouts.
2024/12/05:
Working on adding timeout to both async_connect and connect calls.
2024/12/06:
Implemented timeout on synchoronous connect call. Looking to modify server mock to force timeouts and run tests.
2024/12/09:
Further investigation and tests over http synchronous connect call. No satisfactory results yielded, will focus on asynchronous connect moving forward.
2024/12/10:
Trying different approaches to setting a timeout. So far I've failed to devise a way to reliably test my prototype.
2024/12/11:
Successfully implemented and tested a timeout for HttpSocket::Connect() function. Moving on to implement the same in https, read and write.
Description
As part of the development of the communicator component of the new agent, we chose to use boost asio/beast as our networking library, which also works with C++20 coroutines.
The first implementation is missing to check for many network errors that can occur during communication. Currently, any failure is not reported correctly and no recovery attempt is made, so we need to improve error handling.
Tasks to be done:
Errors reported during testing
When performing manual tests for other developments we have already encountered some cases that we have to solve:
Handle jwt exceptions
In the following line
if (const auto decoded = jwt::decode<jwt::traits::nlohmann_json>(*m_token); decoded.has_payload_claim("exp"))
a case occurred where a token was returned with an invalid jwt format and the co-routine that handled this task crashed, causing no further attempt to obtain the token and no errors were logged.
Chrash when getting reference from null object
In the following line
return nlohmann::json::parse(boost::beast::buffers_to_string(res.body().data())).at("token").get_ref<const std::string&>();
if the json object has a different format than expected causing “token” to not be where you are looking for it, it causes the crash when trying to do the get_ref() since the at() above would fail.
Example of response that produces the crash:
End of co-routines in case of write/read failure
In Co_PerformHttpRequest when a failure occurs during AsyncWrite/AsyncRead the co_routine is being terminated completely, the correct operation of this should be:
but do not stop the co-routine.
Timeouts in operations with sockets
Timeouts must be added to all socket operations that can block the process/co_routine indefinitely. For example Connect, Write and Read.
The text was updated successfully, but these errors were encountered: