Dubbo consumers unable to connect to the service provided by the producer? Intranet IP?

Source: Internet
Author: User
Tags zookeeper firewall

Environment: Cent OS 7.0 background:

The title of this article can be set as follows because he is the same workaround:
(1) Why Dubbo automatically use the intranet IP when registering zookepper.
(2) Dubbo Consumers cannot connect to the service provided by the producer
(3) ... Scene Restore

1. Project Deployment Framework

Recently in the development of a project, the use of the Dubbo service, the following is the case of project deployment,

The details are as follows (the IP address does not have the connectivity, for the specific situation assumes that everyone should not try.) ):

1, Server A on the deployment of Dubbo service producers, public network ip:139.229.17.226, intranet ip:10.12.11.3;

2, Server B deployed the Dubbo Registry Service zookeeper and Dubbo Background Management Interface program dubbo-admin, public network ip:139.229.17.227, intranet ip:10.12.11.4;

3, Development machine C is my own PC, for the development of Dubbo service consumer projects, the remote request to send the IP address is: 169.254.45.169;
1 2 3 4 5 1 2 3 4 5

Server A and B are servers that are located on the public IP (Alibaba Cloud server).

2, the problems encountered

1, the producer successfully deployed to server A;
2, the producer can successfully register to the Zookeeper Center and Zookeeper service is normal;
3, all the required ports have been opened (through the firewall settings);
4, the producer project, the consumer project uses the Dubbo IP address is the public network IP, and is correct;

In the above scenario, the Dubbo consumer on the development machine C cannot find the Dubbo producer running on Server A, and an error occurs:

caused by:java.lang.IllegalStateException:Failed to check the status of the service Com.ufind.server.facade.JointModule Façade. No provider available for the service com.ufind.server.facade.jointmodulefacade:1.0.0 from the URL zookeeper:// 139.229.17.226:2181/com.alibaba.dubbo.registry.registryservice?anyhost=true&application=ufind_security &check=false&cluster=failfast&dubbo=2.8.4&executes=10&generic=false&interface= Com.ufind.server.facade.jointmodulefacade&methods=pageallillegalrequirements,evaluateidentify,focuson, Listallrequirementmainpage,findprobaseinfobyproid,firstpartyevaluate,viewprojectlist,getprostatus, Firstpartyacceptance,secondpartyacceptance,viewthisproject,getevaluatefirsttosecond,deletesignup, Secondpartyevaluate,updatejointindex,acceptanceidentity,find,adminacceptance,getevaluatesecondtofirst,signup, Getprojointwithspid,returnfocusorsignup,checkin,listallacptrqr,signupcheck,viewthisprojectsimple, Getprojointwithfpid,findwhosignmyrequire,getprojointwithfpidshowusername&organization=myufind&owner=liugen.xu&pid=15924&revision=1.0.0- snapshot&side=consumer&timeout=500000&timestamp=1475137563583&version=1.0.0 to the consumer
 169.254.45.169 Use Dubbo version 2.8.4
1 2 3 1 2 3

You can see the service name: com.ufind.server.facade.jointmodulefacade:1.0.0;
Registration Center: zookeeper://139.229.17.226:2181;

This means that the provider of this service is not found in this and the registry, but it does exist in Dubbo-admin:

It is worth noting that this place's IP address is my server A's intranet IP address, and then found a wrong place as follows:

15:18:30 [WARN] abstractclient.<init>:112-[]-[Dubbo] Failed to start nettyclient desktop-nt000ep/169.254.45.169 Connect to the server/10.12.11.3:20880 (check = = False, ignore and retry later!), cause:client (omit specific service name) failed to Conn ECT to server/10.47.184.14:20880 client-side timeout 3000ms (elapsed:3040ms) from Netty client 169.254.45.169 using Dubb o version 2.8.4, Dubbo version:2.8.4, current host:169.254.45.169

com.alibaba.dubbo.remoting.RemotingException: Client (omit specific service full name) failed to connect to server/10.47.184.14:20880 client-side Timeout 3000ms (elapsed:3040ms) from Netty Client 169.254.45.169 using Dubbo version 2.8.4
1 2 3 4 1 2 3 4

It means to get the service from: server/10.12.11.3:20880, it is obvious that this is an intranet IP address, but it appears on my development machine C, that is, my local development machine C is unable to find the public IP server network IP address, Therefore, the services provided by Dubbo producers cannot be obtained.

Whether this is the case, did an experiment, the producers and consumers are deployed to another Alibaba Cloud Server C, as follows:

It turns out that the result is correct, in the same network environment, the same configuration is not a problem, that is, in a unified environment, the intranet can communicate with each other.

So the problem is that in my project Dubbo the producer's registry IP, Dubbo service consumer Registration center IP is set to the public IP, but why through the registration center of this program, consumers find the IP address of the producer into the intranet IP address. The root of the problem

Dubbo Service consumers in the Zookeeper service Center when looking for services, zookeeper will Dubbo service producers of the intranet address to consumers, so will appear: client (omit the specific service full name) failed to connect to server/10.47.184.14:20880

In this case, for development machine C, the intranet is not accessible, so the provider can not find the service.

Find out the cause of the problem, then what is the cause of this problem?

This is because in the file configured by the server hosts, the host name is pointed to the intranet IP address, and the hosts configuration file for my server A and B is as follows:

The Hosts file for Server A is:

127.0.0.1 localhost
:: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.12.11.3  Iz132oqrrt7uz
1 2 3 4 1 2 3 4

The Hosts file for Server B is:

127.0.0.1 localhost
:: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.12.11.3  iz132oqrrt7uz
10.12.11.4  Izuf6gd6n1wwjoz
1 2 3 4 5 1 2 3 4 5

Can be seen above, the host name points to the intranet IP, so you need to change them back to the specific public IP address, or directly delete, you can solve the problem.

The respective corresponding changes are as follows:

127.0.0.1 localhost
:: 1             localhost localhost.localdomain localhost6 localhost6.localdomain6
139.229.17.226  Iz132oqrrt7uz
1 2 3 4 1 2 3 4
127.0.0.1 localhost
:: 1             localhost localhost.localdomain localhost6 localhost6.localdomain6
139.229.17.226  iz132oqrrt7uz
139.229.17.227  Izuf6gd6n1wwjoz
1 2 3 4 5 1 2 3 4 5

Then restart: Zookeeper service –> Restart the Dubbo service producer –> Restart the Dubbo service consumer to run successfully.

You can see that the IP address above has become the IP address of the public network, and then re-run the Dubbo consumer Project on its own development machine C, can also run successfully, get the service provided by the producer. Summary

If you are sure that all of your configuration is correct, the specified zookeeper registry IP address is correct, all the ports used have been configured through the firewall, encountered can not obtain the service provided by the producer, or registration failure, and so on, it may be possible to see whether it is caused by the intranet IP.

Because, my project uses Alibaba Cloud Server, there are two, that is, server A and Server B in the above, after encountering this problem found that Alibaba cloud default for us to the network IP and host name of the association, that is, the Hosts file configuration:

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.