-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate if the http client library is closing sockets as expected #564
Comments
Windows: PS C:\Users\54358\Downloads> netstat -ano | findstr :27000
TCP 127.0.0.1:27000 0.0.0.0:0 LISTENING 22332
TCP 192.168.0.4:62813 192.168.0.177:27000 TIME_WAIT 0
TCP 192.168.0.4:62814 192.168.0.177:27000 ESTABLISHED 14616
TCP 192.168.0.4:62815 192.168.0.177:27000 TIME_WAIT 0
TCP 192.168.0.4:62816 192.168.0.177:27000 TIME_WAIT 0
PS C:\Users\54358\Downloads> netstat -ano | findstr :27000
TCP 127.0.0.1:27000 0.0.0.0:0 LISTENING 22332
TCP 192.168.0.4:62813 192.168.0.177:27000 TIME_WAIT 0
TCP 192.168.0.4:62814 192.168.0.177:27000 ESTABLISHED 14616
TCP 192.168.0.4:62815 192.168.0.177:27000 TIME_WAIT 0
TCP 192.168.0.4:62816 192.168.0.177:27000 TIME_WAIT 0
PS C:\Users\54358\Downloads> netstat -ano | findstr :27000
TCP 127.0.0.1:27000 0.0.0.0:0 LISTENING 22332
TCP 192.168.0.4:62814 192.168.0.177:27000 ESTABLISHED 14616
PS C:\Users\54358\Downloads> netstat -ano | findstr :27000
TCP 127.0.0.1:27000 0.0.0.0:0 LISTENING 22332
PS C:\Users\54358\Downloads> netstat -ano | findstr :27000
TCP 127.0.0.1:27000 0.0.0.0:0 LISTENING 22332 Ubuntu: root@nico-VirtualBox:/home/nico/wazuh-agent/build# ss -tanp | grep :27000
TIME-WAIT 0 0 192.168.0.59:52254 192.168.0.177:27000
ESTAB 0 0 192.168.0.59:50656 192.168.0.177:27000 users:(("wazuh-agent",pid=7375,fd=16))
TIME-WAIT 0 0 192.168.0.59:52270 192.168.0.177:27000
root@nico-VirtualBox:/home/nico/wazuh-agent/build# ss -tanp | grep :27000
TIME-WAIT 0 0 192.168.0.59:52254 192.168.0.177:27000
ESTAB 0 0 192.168.0.59:50656 192.168.0.177:27000 users:(("wazuh-agent",pid=7375,fd=16))
TIME-WAIT 0 0 192.168.0.59:52270 192.168.0.177:27000
root@nico-VirtualBox:/home/nico/wazuh-agent/build# ss -tanp | grep :27000
TIME-WAIT 0 0 192.168.0.59:48822 192.168.0.177:27000
ESTAB 0 0 192.168.0.59:34580 192.168.0.177:27000 users:(("wazuh-agent",pid=7375,fd=16))
TIME-WAIT 0 0 192.168.0.59:48810 192.168.0.177:27000
root@nico-VirtualBox:/home/nico/wazuh-agent/build# ss -tanp | grep :27000
ESTAB 0 0 192.168.0.59:41926 192.168.0.177:27000 users:(("wazuh-agent",pid=7375,fd=16))
TIME-WAIT 0 0 192.168.0.59:54208 192.168.0.177:27000
TIME-WAIT 0 0 192.168.0.59:54212 192.168.0.177:27000 It is recommended and good practice to explicitly close the connection, as this frees up resources more quickly and avoids possible connection crashes. |
Research for HTTPFor http connections the Wazuh Agent uses an object of the class boost::beast::tcp_stream, reading the official documentation of this class does not refer to a correct or recommended way to close the socket. Browsing a little more in the documentation of the class “boost::beast::tcp_stream” we can find examples of implementation of a client/server application, here we find reference to how to close the socket.
Research for HTTPSFor https connections the Wazuh Agent uses an object of the class boost::beast::ssl_stream, reading the official documentation of this class does not refer to a correct or recommended way to close the socket. Browsing a little more in the documentation of the class “boost::beast::ssl_stream” we can find examples of implementation of a client/server application, here we find reference to how to close the socket. |
Update 21/03/2025After further investigation it was found that the socket is closing, it is the destructor of the tcp_stream object that closes it. The The missing step in the disconnection is to perform the |
Update
|
Description
The http client library uses Boost Beast's HTTP and HTTPS sockets to execute requests.
Every time a new request is executed, a new socket is created which is used to create the communication with the server.
Additionally, sockets have a
Close
function which must be called at the end of the operation to properly close the socket. However, this function is not currently being used and needs to be evaluated.Tasks
Close
socket functions and in which cases they should be called.The text was updated successfully, but these errors were encountered: