implement msg receive with timeout