'Reconnect to the data server.'

def _Reconnect(self):

    try:
        if self.sock:
            self.sock.close()
    except socket.error:
        pass
    try:
        if self.conn:
            self.conn.close()
    except httplib.HTTPException:
        pass
    try:
        self.conn = httplib.HTTPConnection(self.Address(), self.Port())
        username = config.CONFIG.Get('HTTPDataStore.username')
        password = config.CONFIG.Get('HTTPDataStore.password')
        if (not username):
            raise HTTPDataStoreError('HTTPDataStore.username    not    provided')
        if (not password):
            raise HTTPDataStoreError('HTTPDataStore.password    not    provided')
        self.conn.request('POST', '/client/handshake', '', {})
        response = self.conn.getresponse()
        if (response.status != constants.RESPONSE_OK):
            logging.warning('Could    not    handshake    the    server    %s:%d', self.Address(), self.Port())
            return False
        size_nonce = int(response.getheader('Content-Length'))
        nonce = response.read(size_nonce)
        rdf_token = auth.NonceStore.GenerateAuthToken(nonce, username, password)
        token = rdf_token.SerializeToString()
        headers = {'Content-Length': len(token)}
        self.conn.request('POST', '/client/start', token, headers)
        self.sock = self.conn.sock
        self.sock.setblocking(1)
        self.sock.settimeout(config.CONFIG['HTTPDataStore.login_timeout'])
        ack = self._ReadExactly(3)
        if (ack == 'IP\n'):
            raise HTTPDataStoreError('Invalid    data    server    username/password.')
        if (ack != 'OK\n'):
            return False
        logging.info('Connected    to    data    server    %s:%d', self.Address(), self.Port())
        return True
    except httplib.HTTPException as e:
        logging.warning('Httplib    problem    when    connecting    to    %s:%d:    %s', self.Address(), self.Port(), str(e))
        return False
    except (socket.error, socket.timeout, IOError) as e:
        logging.warning('Socket    problem    when    connecting    to    %s:%d:    %s', self.Address(), self.Port(), str(e))
        return False
    return False
