handle do_handshake_on_connect and read errors