Mozartaa opened a new issue #8523:
URL: https://github.com/apache/dubbo/issues/8523


   - [ ] I have searched the 
[issues](https://github.com/apache/dubbo/issues/3930) of this repository and 
believe that this is not a duplicate.
   - [ ] I have checked the 
[FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository 
and believe that this is not a duplicate.
   
   
   Hi,when we export a service, if we do not configure the host of the service, 
dubbo will automatically obtain the local machine IP. As shown in the code 
below:【ServiceConfig#findConfigedHosts】
   ```java
   hostToBind = InetAddress.getLocalHost().getHostAddress();
   ```
   When my computer has multiple network adapters, dubbo reads a virtual 
network adapter. The virtual network adapter was used for registration, but the 
virtual network adapter cannot provide services to the outside world, causing 
the consumer to fail to call the service provider successfully.
   Therefore, I think that when obtaining the machine IP, some judgments should 
be made to obtain an IP address that can provide services.
   
   ### Environment
   
   * Dubbo version: 2.7.3
   * Operating System version: Windows10
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1. config the dubbo
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <beans xmlns="http://www.springframework.org/schema/beans";
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
          xmlns:dubbo="http://dubbo.apache.org/schema/dubbo";
          xsi:schemaLocation="http://www.springframework.org/schema/beans       
 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd        
http://dubbo.apache.org/schema/dubbo        
http://dubbo.apache.org/schema/dubbo/dubbo.xsd";>
   
       <dubbo:application name="hello-world-app"/>
       <dubbo:registry address="zookeeper://XXXX:2181"/>
       <dubbo:protocol name="dubbo" port="20880"/>
       <dubbo:service interface="com.huawei.api.HelloService" 
ref="helloService"/>
       <bean id="helloService" class="com.huawei.impl.HelloServiceImpl"/>
   </beans>
   ```
   2. start the provider service
    ```java
   public static void main(String[] args) throws Exception {
                ClassPathXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext("provider.xml");
                applicationContext.start();
                System.in.read();
        }
   ```
   3.query the zookeeper.
   The provider service used a virtual IP when registering.
   
   
![图片](https://user-images.githubusercontent.com/43882950/129580481-6a3ce6b5-681f-4bc2-8326-a6dca8a6ba6d.png)
   
![图片](https://user-images.githubusercontent.com/43882950/129580969-ffb61800-4dae-41e5-877a-3eed6795f9e4.png)
   
   
   4. consumer call provider failed.
   
![图片](https://user-images.githubusercontent.com/43882950/129580934-d68104a9-6355-4c96-a809-5f712cab3f58.png)
   
   
   Pls. provide [GitHub address](https://github.com/Mozartaa) to reproduce this 
issue.
   
   ### Expected Result
   
   Expect the provider can provide service normally.
   
   ### Actual Result
   
   The provider service used a virtual IP when registering.
   
   If there is an exception, please attach the exception trace:
   
   ```
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to