fixed on_connect and on_error callbacks