From that "Main: TIMEOUT" message you reported, it sounds like your
application (which is using libssh2) has some sort of overall
timeout/timer set. Is it possible that that timer is being exceeded
unexpectedly, or set too short?