Avoid blocking on ping request.

Thanks @icereval for the code.