Dubbo Unable to access remote zookeeper registered service issues

Source: Internet
Author: User

Background

When using Dubbo, it was found that when zookeeper, dubbo-admin, producers and consumers were
In the intranet, the production and consumption of producers is no problem, but when it zookeeper, producers put on the remote server, and then consumers in the access to consumption there is no way to find a service problem.

Use of intranet environment

The above diagram is in the same intranet, using the following code:

1. Producer Configuration

<?xml version= "1.0" encoding= "UTF-8"?><beans  xmlns  =< Span class= "Hljs-value" > "Http://www.springframework.org/schema/beans"  xmlns:  XSI  = "http://www.w3.org/2001/XMLSchema-instance"  xmlns:dubbo  = "http://code.alibabatech.com/schema/ Dubbo " xsi:schemalocation  =" HTTP +/ Www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://cod E.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd ";     <dubbo:application name="jhd_security" owner="Allen.xu"  Organization="Myjhd"/>    <dubbo:registry Address="zookeeper://172.16.61.101:2181" timeout ="500000" Group="Jhdgroup" id="myjhd_id"/>    <!--Exposed interface--    <bean  id  = "Dubbodemofacade"  class  = "Com.dubbo.demo.facade.impl.DubboDemoFacade" />     <dubbo:serviceref= "dubbodemofacade"interface=" Com.dubbo.demo.facade.IDubboDemoFacade "version=" 1.0.0 "cluster=" FailFast "  Executes="Ten"timeout="500000"registry="Myjhd_ ID ">                                                                                        </dubbo:service></Beans>

2. Consumer Configuration

<?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://code.alibabatech.com/schema/dubbo"xsi:schemalocation="http ://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd/http Code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">                         <dubbo:application name= "consumer-of-sayhello-app" owner=" Allen.xu " Organization=" Myjhd "/>    <dubbo:registry Address="zookeeper://172.16.61.101:2181" timeout ="500000" Group="Jhdgroup" id="myjhd_id"/>   <dubbo:reference id= "dubbodemofacade"interface=" Com.dubbo.demo.facade.IDubboDemoFacade "version=" 1.0.0 "cluster=" FailFast "  Timeout="500000"registry="myjhd_id"/>                                                                                                         </Beans>

3. Demo Effect

You can see that the IP of the producer and the consumer is the same, and it can be run locally.

Usage of multi-network environment

If the above-mentioned IP address is modified according to the relevant zookeeper, and other without modification, using the upper code, the producer can register to the registry, but the consumer cannot consume the service.

Producer information can be seen on dubbo-admin, but consumers are not able to use the service because of a firewall problem.

You can see that the top of the port is 20880, which is Dubbo default, the consumer when consuming the service will also go through the port to use the service, so modify the firewall list.

Add the following in/etc/sysconfig/iptables:

-A-m--NEW-m-p--20880-j ACCEPT

Indicates that port 20880 is turned on

Then: Restart the service iptables restart firewall.

Another way is that we can specify the port of the producer consumer, which can be

<dubbo:protocol name="dubbo" port="8889"/>

In this case, you can also turn on port 8889.

Dubbo Unable to access remote zookeeper registered service issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.