I was getting this -43 when connecting to servers on high latency networks.
Libssh2.h has this definition...
define LIBSSH2_ERROR_SOCKET_RECV -43
I was able successfully connect consistently by adding a short sleep between the libssh2_session_init() call and the libssh2_session_handshake(session, sock) call like this...
session = libssh2_session_init();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
libssh2_session_handshake(session, sock);
I chanced upon this solution by single stepping over the original code in the debugger, and it would successfully connect every time, so I tried the sleep and it worked. I tried some different sleep times, with 30ms being the lowest value that still worked.
I found your post while trying to find an explanation for this behavior. I hope this method works for you.