Ansible sometimes encountered error 'SSH encountered an unknown error during the connection. '

I am pretty sure the private key and user are correct for ansible script because we only occasionally see this error. So I suspect the network connection can not be reached sometimes or SSH service is not started on remote server. So before ansible playbook ran, I want to call ping module to make sure network connection is ok, but I do not know if ansible has a module can check ssh service is ok, does telnet module work?

wait_for can check if a port is open, the ping module actually uses
the ssh connection, it can be used with do/until to make sure the
machine is up.