In the use of Win10 system development, when we do not use the registry to deploy spring-boot-admin and the corresponding client, may appear admin-server can not pull the client side monitoring information problem, the solution is very simple, just need to add the following line of configuration in the client test:

spring.boot.admin.client.instance.prefer-ip: true Register with IP
Copy the code

The analysis reason

When starting the client, we found the following error on the server

failed to resolve 'xxx.mshome.net' after 4 queries ; nested exception is java.net.UnknownHostException: failed to resolve 'LAPTOP-CDQ9PAID.mshome.net' after 4 queries
Copy the code

It appears to be a problem caused by XXX.mshome.net. We queried the local DNS cache and found the following record:

ARPA 1.224.17.172. The in - addr. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- record name....... : 1.224.17.172. The in - addr. ARPA. Record type....... : 12 survival time....... : 0 data length....... : 8 parts......... : answer PTR records...... : xxx.mshome.netCopy the code

First, explain two domains: in-Addr. ARPA and mshome.net

in-addr.arpa

ARPA is a top-level domain name used specifically for Internet infrastructure. Now he has two secondary domain names:

  • The in – addr. ARPA. IPv4 DNS reverse lookup
  • Ip6. ARPA. IPv6 DNS reverse lookup

DNS domain name resolution is to resolve a domain name to an IP address, whereas reverse lookup is to resolve an IP address to a domain name.

mshome.net

This domain name is Microsoft’s, when we use Windows Network Connection Sharing (ICS), if the host does not have a domain name, the system will automatically configure this domain name.

To solve

The spring-admin server printed an error message indicating that the xxx.mshome.net domain name could not be processed. Let’s take a closer look at the processing. Since the server and client interact in a heartbeat, we only need to focus on how the client gets the domain name. When the client starts, Service will be automatically registered a DefaultApplicationRegistrator, the bean will call DefaultApplicationRegistrator# will register method The Application created by applicationFactor #createApplication is registered with the server. Application#managementUrl = xxx.mshome.net. Through the call chain, we see that we end up calling InetAddress#getLocalHost, where localAddrs[0] is taken, which happens to be the address represented by xxx.mshome.net. So why is configured with the above parameters was no problem, mainly DefaultApplicationFactory# getHost this method:

protected String getHost(InetAddress address) {
		return this.instance.isPreferIp() ? address.getHostAddress() : address.getCanonicalHostName(); // When prefer-ip=true, use IP instead of domain name, 172.17.224.1
	}
Copy the code

How did mshome.net come about

Ipconfig Prints network configurations

Ethernet adapter vEthernet (WSL): Connect specific DNS suffix....... : local link IPv6 address........ : Fe80: : 618 e: d3dc: c21b: b510%68 IPv4 addresses............ : 172.17.224.1 subnet mask............ : 255.255.240.0 Default gateway............. :Copy the code

Discover this is WSL network!

conclusion

It is best to add this configuration in case of unknown errors

spring.boot.admin.client.instance.prefer-ip: true # use IP
Copy the code