{"record":{"id":"5cc065f8775787c5","repo":"mRemoteNG/mRemoteNG","slug":"failed-to-resolve-address-address","errorCode":null,"errorMessage":"Failed to resolve address '{address}'","messagePattern":"Failed to resolve address '(.+?)'","errorType":"exception","errorClass":"VaultOpenbaoException","httpStatus":null,"severity":"error","filePath":"ExternalConnectors/VO/VaultOpenbao.cs","lineNumber":61,"sourceCode":"                    throw new VaultOpenbaoException($\"Backend of type ldap does not match expected type {VaultOpenbaoSecretEngine}\");\n                case \"ssh\" when VaultOpenbaoSecretEngine != 3:\n                    throw new VaultOpenbaoException($\"Backend of type ssh does not match expected type {VaultOpenbaoSecretEngine}\");\n            }\n        }\n        public static void ReadOtpSSH(string mount, string role, string? username, string address, out string password) {\n            VaultClient vaultClient = GetClient();\n            TestMountType(vaultClient, mount, 3);\n            if (!IPAddress.TryParse(address, out _)) {\n                try {\n                    var addrs = Dns.GetHostAddressesAsync(address).Result;\n                    if (addrs == null || addrs.Length == 0) {\n                        throw new VaultOpenbaoException($\"Could not resolve address '{address}'\");\n                    }\n                    // Prefer IPv4, otherwise take first available\n                    var selected = addrs.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork) ?? addrs[0];\n                    address = selected.ToString();\n                } catch (Exception ex) {\n                    throw new VaultOpenbaoException($\"Failed to resolve address '{address}'\", ex.Message);\n                }\n            }\n            var otp = vaultClient.V1.Secrets.SSH.GetCredentialsAsync(role, address, username, mount).Result;\n            password = otp.Data.Key;\n\n        }\n        public static void ReadPasswordSSH(int secretEngine, string mount, string role, string username, out string password) {\n            VaultClient vaultClient = GetClient();\n            TestMountType(vaultClient, mount, secretEngine);\n            switch (secretEngine) {\n                case 0:\n                    var kv = vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync(role, mountPoint: mount).Result;\n                    password = kv.Data.Data[username].ToString() ?? string.Empty;\n                    return;\n                default:\n                    throw new VaultOpenbaoException($\"Backend of type {secretEngine} is not supported\");\n            }\n        }","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/mRemoteNG/mRemoteNG/blob/9211babf35209d6171c8ff6e73bd856f11df21a5/ExternalConnectors/VO/VaultOpenbao.cs#L43-L79","documentation":"Thrown by ReadOtpSSH's catch-all when Dns.GetHostAddressesAsync itself throws (rather than returning empty). The second argument (ex.Message) carries the underlying DNS exception text. It is the wrapper for any DNS-layer failure: socket error, timeout, DNS server unreachable.","triggerScenarios":"GetHostAddressesAsync throws SocketException (DNS server unreachable, transient network failure, hostname too long, malformed hostname), or any other Exception from the DNS layer.","commonSituations":"Network/DNS server outage at call time; no network connectivity (offline machine); transient DNS timeout under load; corporate DNS server temporarily down; hostname contains invalid characters.","solutions":["Inspect the inner message (ex.Arguments / the second constructor arg) — it is the original DNS exception text and names the real cause (e.g., 'No such host is known').","Retry once after a short delay for transient DNS/network failures.","Verify network connectivity and DNS server reachability from the machine.","Fall back to an IP address if the hostname is unreliable, bypassing DNS entirely (IPAddress.TryParse path).","Catch VaultOpenbaoException and surface both the address and the inner DNS error to the user."],"exampleFix":"// before\n} catch (Exception ex) {\n    throw new VaultOpenbaoException($\"Failed to resolve address '{address}'\", ex.Message);\n}\n\n// after\n} catch (Exception ex) {\n    throw new VaultOpenbaoException($\"Failed to resolve address '{address}': {ex.Message}\", ex.Message);\n}","handlingStrategy":"retry","validationCode":"// Wrap DNS resolution with a single retry for transient failures\nstatic IPAddress[] ResolveWithRetry(string address)\n{\n    try { return Dns.GetHostAddresses(address); }\n    catch (SocketException) { System.Threading.Thread.Sleep(500); return Dns.GetHostAddresses(address); }\n}","typeGuard":"if (ex is VaultOpenbaoException v && v.Message.StartsWith(\"Failed to resolve\")) { /* DNS-layer exception; check inner (v.Arguments) for cause */ }","tryCatchPattern":"try { VaultOpenbao.ReadOtpSSH(mount, role, username, address, out var pass); }\ncatch (VaultOpenbaoException ex) when (ex.Message.StartsWith(\"Failed to resolve\"))\n{ /* transient DNS or network: inspect ex.Arguments, optionally retry once */ }","preventionTips":["Inspect the inner DNS message (the second constructor arg) for the real cause.","Retry once for transient DNS/network failures; do not retry indefinitely.","Verify network connectivity and DNS server reachability.","Fall back to an IP address when hostname resolution is unreliable."],"tags":["vault","openbao","dns","network","external-connectors"],"backgroundTag":null,"analyzedSha":"9211babf35209d6171c8ff6e73bd856f11df21a5","analyzedAt":"2026-08-13T19:31:27.817Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}