You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/08/16 14:41:17 UTC

[GitHub] [dubbo] Mozartaa opened a new issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
BurningCN commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-900032227


   看报错,你这个是消费者发起订阅的时候没有拿到提供者列表吧?和ip有关吗?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Mozartaa commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
Mozartaa commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-903111515


   您好,非常感谢回复!
   但是我想表达的问题是一个优化兼容问题,同样的代码在不同的机器上问题是不一样的。这个问题我遇到了,是因为我电脑有多个网卡,但是dubbo并没有做兼容,在其他机器没有问题,只不过他们网卡单一,或者获取的ip是ok的。这个问题不是必现的,但是是可以优化的,希望您看一下我上封邮件中的帖子。如果对它进行了优化,那么dubbo的功能可以更加完善。
   
   https://blog.csdn.net/f641385712/article/details/105233229
   
   
   ------------------&nbsp;原始邮件&nbsp;------------------
   发件人:                                                                                                                        "apache/dubbo"                                                                                    ***@***.***&gt;;
   发送时间:&nbsp;2021年8月20日(星期五) 中午11:38
   ***@***.***&gt;;
   ***@***.******@***.***&gt;;
   主题:&nbsp;Re: [apache/dubbo] 【call provider service failed】The provider service used a virtual IP when registering (#8523)
   
   
   
   
   
    
   你好,我自己试了下。我用的dubbo里的dubbo-demo-xml-provider和dubbo-demo-xml-consumer案例功能是正常的(最新版本),能正常消费,提供者案例代码也没有配置ip
    
   
    
   —
   You are receiving this because you authored the thread.
   Reply to this email directly, view it on GitHub, or unsubscribe.
   Triage notifications on the go with GitHub Mobile for iOS or Android.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
BurningCN commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-900230122


   > > 看报错,你这个是消费者发起订阅的时候没有拿到提供者列表吧?和ip有关吗?
   > 
   > 有关的,这个ip不能对外提供服务,如果我暴露服务的时候指定host,就可以成功调用
   
   能把你的消费者代码也发一下吗?我本地用你的用例试下看看


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
BurningCN commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-902406410


   你好,我自己试了下。我用的dubbo里的dubbo-demo-xml-provider和dubbo-demo-xml-consumer案例功能是正常的(最新版本),能正常消费,提供者案例代码也没有配置ip
   
   ![image](https://user-images.githubusercontent.com/43363120/130175412-a5f73ad0-1951-4e96-8232-f9ce89bb7419.png)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-903489104


   > 但是我想表达的问题是一个优化兼容问题,同样的代码在不同的机器上问题是不一样的。这个问题我遇到了,是因为我电脑有多个网卡,但是dubbo并没有做兼容,在其他机器没有问题,只不过他们网卡单一,或者获取的ip是ok的。这个问题不是必现的,但是是可以优化的,希望您看一下我上封邮件中的帖子。如果对它进行了优化,那么dubbo的功能可以更加完善。
   
   在 #5801 已经优化过一次了


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] CrazyHZM commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
CrazyHZM commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-925399247


   Try it with the latest version, if you still have problems, you can open the issues at any time.
   @Mozartaa 


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Mozartaa commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
Mozartaa commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-900146449


   > 
   > 
   > 看报错,你这个是消费者发起订阅的时候没有拿到提供者列表吧?和ip有关吗?
   
   有关的,这个ip不能对外提供服务,如果我暴露服务的时候指定host,就可以成功调用


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Mozartaa commented on issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
Mozartaa commented on issue #8523:
URL: https://github.com/apache/dubbo/issues/8523#issuecomment-900323863


   您好,感谢回复!
   &nbsp; &nbsp; 这个报错和代码其实没有关系,我使用的是最基本的Hello World代码,主要原因在于当我电脑有多个网卡时,dubbo没有进行正确判断区分,使用了错误的网卡对外提供服务,导致服务不可用。
   报错原因分析如下:
   &nbsp; &nbsp; 1.在provider的配置文件中,配置协议时我没有配置host信息。
   
   2.由于没有配置host信息,dubbo会读取我本机IP,并且把机器IP注册到zookeeper中。如下:
   可以看到注册到zookeeper中的ip是一个VMWare的虚拟网卡的IP,这个IP使用 telnet命令是连接不到的。因为这个IP不能对外提供服务。
   
   
   (1)查看本机IP
   
   (2)查看zookeeper中注册信息
   
   
   
   3.通过debug consumer的代码,可以发现可以从注册中心获取到provider地址,但是使用这个虚拟IP,导致网络不通。如果在provider的配置文件中加上正确的host配置,不用dubbo自动获取IP,则consumer可以正确调用。
   
   
   4.查看dubbo源码,可以发现在ServiceConfig类中,有一个findConfigedHosts()方法,如果配置文件没有配置host信息,这个方法会读取机器IP,使用如下的方式,但是这个获取机器IP的方式是有问题的,导致获取到的是虚拟网卡的IP地址,不能正确对外提供服务。具体原因可以参考下边的帖子。
   
   
   &nbsp; &nbsp; &nbsp;hostToBind = InetAddress.getLocalHost().getHostAddress();
   
   
   InetAddress.getLocalHost()问题解释:https://blog.csdn.net/f641385712/article/details/105233229
   
   
   建议获取机器IP地址的代码进行优化,可以参考下方代码:
   
   
   
   
   
   ------------------&nbsp;原始邮件&nbsp;------------------
   发件人:                                                                                                                        "apache/dubbo"                                                                                    ***@***.***&gt;;
   发送时间:&nbsp;2021年8月17日(星期二) 晚上7:52
   ***@***.***&gt;;
   ***@***.******@***.***&gt;;
   主题:&nbsp;Re: [apache/dubbo] 【call provider service failed】The provider service used a virtual IP when registering (#8523)
   
   
   
   
   
      
   看报错,你这个是消费者发起订阅的时候没有拿到提供者列表吧?和ip有关吗?
     
   有关的,这个ip不能对外提供服务,如果我暴露服务的时候指定host,就可以成功调用
     
   能把你的消费者代码也发一下吗?我本地用你的用例试下看看
    
   —
   You are receiving this because you authored the thread.
   Reply to this email directly, view it on GitHub, or unsubscribe.
   Triage notifications on the go with GitHub Mobile for iOS or Android.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] CrazyHZM closed issue #8523: 【call provider service failed】The provider service used a virtual IP when registering

Posted by GitBox <gi...@apache.org>.
CrazyHZM closed issue #8523:
URL: https://github.com/apache/dubbo/issues/8523


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org