private function validateConnection($baseUri) {
        $parts = parse_url($baseUri);
        $host = $parts['host'];
        $port = isset($parts['port']) ? $parts['port'] : ($parts['scheme'] === 'https' ? 443 : 80);

        set_error_handler(function () {
            return true;
        });

        $resource = fsockopen($host, $port);
        restore_error_handler();

        if ($resource === false) {
            // Can't connect
            return false;
        }

        // Connection successful, close connection
        fclose($resource);

        return true;
    }