Closed yigemaserwang closed 6 years ago
This example was designed for testing on the same machine.
The Vert.x producer bean creates the Vert.x instance manually. So the clustered event bus options are set to default. In particular, default host = localhost.
If you modify VertxOptions
to use the right host on each machine it should work.
thanks. it work。 in springboot file application.properties ,add "host=192.168.1.102". and in file VertxProducer.java, change to @Value("${host:#{null}}") String host; private Vertx vertx; @PostConstruct void init() throws ExecutionException, InterruptedException { VertxOptions options = new VertxOptions() .setClusterManager(new HazelcastClusterManager(hazelcastInstance)).setClusterHost(host);
i have two computer ,one is macos ,other is windows ,so i run springboot-clustering-hazelcast first on macos ,set Integer port=8081; the other run springboot-clustering-hazelcast ok;
192.168.1.111]:5701 [dev] [3.6.7] Members [2] { Member [192.168.1.102]:5701 Member [192.168.1.111]:5701 this } 2018-10-31 13:40:41.925 INFO 37833 --- [ main] com.hazelcast.core.LifecycleService
when i run " seq 10 | while read i; do curl http://localhost:8081/?name=Thomas${i}; echo; done " on macos terminal as follows:
adeiMac:Users a$ seq 10 | while read i; do curl http://localhost:8081/?name=Thomas${i}; echo; done Timed out after waiting 30000(ms) for a reply. address: c56bd73e-99e3-4e2e-9584-b8fd61c4aedd, repliedAddress: hello Timed out after waiting 30000(ms) for a reply. address: e0d97d5e-9dea-4d7c-9608-067f987996d2, repliedAddress: hello Timed out after waiting 30000(ms) for a reply. address: 7e0f458f-6874-48c9-b5ea-504a15412847, repliedAddress: hello Timed out after waiting 30000(ms) for a reply. address: cfe85e07-c5c5-4df9-94b9-776f60f7f3b2, repliedAddress: hello
and my eclipse console on macos show as follows: 2018-10-31 13:40:44.768 WARN 37833 --- [ntloop-thread-1] i.v.c.e.impl.clustered.ConnectionHolder : Connecting to server localhost:52360 failed
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:52360 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_192] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_192] at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:325) ~[netty-transport-4.1.19.Final.jar:4.1.19.Final] at io.netty.channel.nio.A