OpenNHP/opennhp · error

relay: server instance # resolve

Error message

relay: server %s instance #%d resolve %s: %w

What it means

Raised in buildServer while registering an upstream instance: net.ResolveUDPAddr failed for the instance's Host:Port string. The configured address for that server instance cannot be parsed/resolved into a UDP endpoint (malformed host, bad port literal, or unresolvable hostname at load time).

Solutions

  1. Fix the host/port pair named in the error message in the relay config
  2. Use an IP literal if DNS is not available at relay startup
  3. Verify the port is a number in range and no stray characters were pasted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at endpoints/relay/relay.go:280 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07). Data as JSON: /api/errors/f1b9f80e80f12b31. Report an issue: GitHub.

Appendix: source

Thrown at endpoints/relay/relay.go:280

	if c.StickyInstance != nil {
		sticky = *c.StickyInstance
	}
	cr := &serverRuntime{
		id:           id,
		name:         c.Name,
		pubKey:       pubKey,
		pubKeyBase64: c.PubKeyBase64,
		scheme:       c.LoadBalance,
		sticky:       sticky,
		instances:    make([]*serverInstance, 0, len(c.Instances)),
	}

	for j := range c.Instances {
		ci := &c.Instances[j]
		addrStr := fmt.Sprintf("%s:%d", ci.Host, ci.Port)
		udpAddr, err := net.ResolveUDPAddr("udp", addrStr)
		if err != nil {
			return nil, fmt.Errorf("relay: server %s instance #%d resolve %s: %w", id, j, addrStr, err)
		}

		// Register the server's pubkey in the device peer table.
		// All siblings share one keypair so device.AddPeer (keyed by
		// pubkey) collapses them to a single entry — that's the
		// intent, not a bug. Routing to a specific instance happens
		// later via serverInstance.addr; validatePeer in the Noise
		// path only consults LookupPeer for pubkey-existence and
		// expiry, and uses ConnData.RemoteAddr (not Peer.Ip) for the
		// per-connection address stickiness check.
		peer := &core.UdpPeer{
			PubKeyBase64: c.PubKeyBase64,
			Ip:           ci.Host,
			Port:         ci.Port,
			Type:         core.NHP_SERVER,
			ExpireTime:   c.ExpireTime,
		}
		rs.device.AddPeer(peer)

View on GitHub (pinned to 6e04ca5ff0)