make zmq wait_valid() more error-proof