BornToBeRoot/NETworkManager · error · FormatException

Could not parse server connection info from input

Error message

Could not parse server connection info from input: {input}

What it means

Parse validated the input against all supported server-connection formats (IPv4, IPv4:port, IPv6, [IPv6]:port, hostname, hostname:port) and none matched, so it aborts by throwing FormatException instead of returning a partially valid ServerConnectionInfo. It fires on malformed user-supplied connection strings such as empty text, 'host:port' with a non-numeric or out-of-range port, or unbracketed IPv6 with a port.

Solutions

  1. Check the input string for typos before passing it to Parse (e.g. 'host:port' with a valid port number).
  2. Wrap IPv6 addresses in square brackets when a port is specified, e.g. '[::1]:3389'.
  3. Ensure the port, if given, is numeric and within 1-65535.
  4. Pre-validate the string with a regex or Uri.TryCreate-style check, or call a TryParse variant if available, before calling Parse.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Source/NETworkManager.Models/Network/ServerConnectionInfo.cs:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BornToBeRoot/NETworkManager@2780d65469 (2026-09-12). Data as JSON: /api/errors/2b94ea1067c570fb. Report an issue: GitHub.

Appendix: source

Thrown at Source/NETworkManager.Models/Network/ServerConnectionInfo.cs:165

        }

        return false;
    }

    /// <summary>
    ///     Parses a server connection string into a <see cref="ServerConnectionInfo" /> object.
    ///     Supports formats: IPv4, IPv4:port, IPv6, [IPv6], [IPv6]:port, hostname, hostname:port
    /// </summary>
    /// <param name="input">Server connection string to parse.</param>
    /// <param name="defaultPort">Default port to use if not specified in input.</param>
    /// <returns>Parsed <see cref="ServerConnectionInfo" /> object.</returns>
    /// <exception cref="FormatException">Thrown when the input string is not in a valid format.</exception>
    public static ServerConnectionInfo Parse(string input, int defaultPort, TransportProtocol transportProtocol)
    {
        if (TryParse(input, out var serverConnectionInfo, defaultPort, transportProtocol))
            return serverConnectionInfo;

        throw new FormatException($"Could not parse server connection info from input: {input}");
    }

    /// <summary>
    ///     Returns a string that represents the current object. IPv6 addresses are bracketed
    ///     (<c>[::1]:53</c>) so the address and port remain distinguishable.
    /// </summary>
    /// <returns>Server:Port, or [Server]:Port for an IPv6 address.</returns>
    public override string ToString()
    {
        return IPAddress.TryParse(Server, out var ip) && ip.AddressFamily == AddressFamily.InterNetworkV6
            ? $"[{Server}]:{Port}"
            : $"{Server}:{Port}";
    }
}

View on GitHub (pinned to 2780d65469)