def connect(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(15.0)
        sock.connect((self.host, self.port))
        set_keepalive(sock, after_idle_sec=10)
        if self.ssl:
            try:
                self.socket = ssl.wrap_socket(sock)
            except ssl.SSLError as e:
                raise RosAPIConnectionError(str(e))
        else:
            self.socket = sock
        self.api_client = RosAPI(self.socket)