我正在运行Julien Ponge的书"Vert中的第三章Infinispan示例。x在行动"在MacOS 11.3上。https://github.com/jponge/vertx-in-action/tree/master/chapter3
public class FirstInstance {
private static final Logger logger = LoggerFactory.getLogger(FirstInstance.class);
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions(), ar -> {
if (ar.succeeded()) {
logger.info("First instance has been started");
Vertx vertx = ar.result();
vertx.deployVerticle("chapter3.HeatSensor", new DeploymentOptions().setInstances(4));
vertx.deployVerticle("chapter3.HttpServer");
} else {
logger.error("Could not start", ar.cause());
}
});
}
}
下载示例代码后,在chapter3文件夹中执行
./gradlew run -PmainClass=chapter3.cluster.FirstInstance -Pjvmargs="-Djava.net.preferIPv4Stack=true"
结果是
failed sending discovery request to /228.6.7.8:46655
这在Windows中工作。我想知道MacOS多播是否有问题?我尝试按照以下步骤启用多播,但仍然得到相同的错误:https://blogs.agilefaqs.com/2009/11/08/enabling-multicast-on-your-macos-unix/
全输出:
News-MacBook-Pro:chapter3f newuser$ ./gradlew run -PmainClass=chapter3.cluster.FirstInstance
> Task :run
DEBUG [main] LoggerFactory - Using io.vertx.core.logging.SLF4JLogDelegateFactory
WARN [vert.x-worker-thread-0] InfinispanClusterManager - Cannot find Infinispan config 'infinispan.xml', using default
WARN [vert.x-worker-thread-0] CONFIG - ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
INFO [vert.x-worker-thread-0] CONTAINER - ISPN000128: Infinispan version: Infinispan 'Corona Extra' 11.0.5.Final
INFO [vert.x-worker-thread-0] CLUSTER - ISPN000078: Starting JGroups channel ISPN with stack jgroups
ERROR [jgroups-6,News-MacBook-Pro-2273] MPING - News-MacBook-Pro-2273: failed sending discovery request to /228.6.7.8:46655
java.io.IOException: Can't assign requested address
at java.base/java.net.PlainDatagramSocketImpl.send(Native Method)
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.jgroups.protocols.MPING.sendMcastDiscoveryRequest(MPING.java:286)
at org.jgroups.protocols.PING.sendDiscoveryRequest(PING.java:63)
at org.jgroups.protocols.PING.findMembers(PING.java:31)
at org.jgroups.protocols.Discovery.invokeFindMembers(Discovery.java:217)
at org.jgroups.protocols.Discovery.lambda$findMembers$0(Discovery.java:228)
at org.jgroups.protocols.Discovery$$Lambda$380.000000009D98CA20.run(Unknown Source)
at org.jgroups.util.TimeScheduler3$Task.run(TimeScheduler3.java:328)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:831)
ERROR [jgroups-6,News-MacBook-Pro-2273] MPING - News-MacBook-Pro-2273: failed sending discovery request to /228.6.7.8:46655
java.io.IOException: Can't assign requested address
at java.base/java.net.PlainDatagramSocketImpl.send(Native Method)
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.jgroups.protocols.MPING.sendMcastDiscoveryRequest(MPING.java:286)
at org.jgroups.protocols.PING.sendDiscoveryRequest(PING.java:63)
at org.jgroups.protocols.PING.findMembers(PING.java:31)
at org.jgroups.protocols.Discovery.invokeFindMembers(Discovery.java:217)
at org.jgroups.protocols.Discovery.lambda$findMembers$0(Discovery.java:228)
at org.jgroups.protocols.Discovery$$Lambda$380.000000009D98CA20.run(Unknown Source)
at org.jgroups.util.TimeScheduler3$Task.run(TimeScheduler3.java:328)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:831)
ERROR [jgroups-6,News-MacBook-Pro-2273] MPING - News-MacBook-Pro-2273: failed sending discovery request to /228.6.7.8:46655
java.io.IOException: Can't assign requested address
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.jgroups.protocols.MPING.sendMcastDiscoveryRequest(MPING.java:286)
at org.jgroups.protocols.PING.sendDiscoveryRequest(PING.java:63)
at org.jgroups.protocols.PING.findMembers(PING.java:31)
at org.jgroups.protocols.Discovery.invokeFindMembers(Discovery.java:217)
at org.jgroups.protocols.Discovery.lambda$findMembers$0(Discovery.java:228)
at org.jgroups.protocols.Discovery$$Lambda$380.000000009D98CA20.run(Unknown Source)
at org.jgroups.util.TimeScheduler3$Task.run(TimeScheduler3.java:328)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:831)
INFO [vert.x-worker-thread-0] GMS - News-MacBook-Pro-2273: no members discovered after 2003 ms: creating cluster as coordinator
INFO [vert.x-worker-thread-0] CLUSTER - ISPN000094: Received new cluster view for channel ISPN: [News-MacBook-Pro-2273|0] (1) [News-MacBook-Pro-2273]
INFO [vert.x-worker-thread-0] CLUSTER - ISPN000079: Channel ISPN local address is News-MacBook-Pro-2273, physical addresses are [192.168.0.101:7800]
INFO [vert.x-eventloop-thread-0] FirstInstance - First instance has been starte
INFO [vert.x-eventloop-thread-5] threads - JBoss Threads version 2.3.3.Final
ERROR [jgroups-5,News-MacBook-Pro-2273] MPING - News-MacBook-Pro-2273: failed sending discovery request to /228.6.7.8:46655
java.io.IOException: Can't assign requested address
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.jgroups.protocols.MPING.sendMcastDiscoveryRequest(MPING.java:286)
at org.jgroups.protocols.PING.sendDiscoveryRequest(PING.java:63)
at org.jgroups.protocols.PING.findMembers(PING.java:31)
at org.jgroups.protocols.Discovery.invokeFindMembers(Discovery.java:217)
at org.jgroups.protocols.Discovery.findMembers(Discovery.java:244)
at org.jgroups.protocols.Discovery.down(Discovery.java:387)
at org.jgroups.protocols.MERGE3$InfoSender.run(MERGE3.java:412)
at org.jgroups.util.TimeScheduler3$Task.run(TimeScheduler3.java:328)
at org.jgroups.util.TimeScheduler3$RecurringTask.run(TimeScheduler3.java:362)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:831)
ERROR [jgroups-6,News-MacBook-Pro-2273] MPING - News-MacBook-Pro-2273: failed sending discovery request to /228.6.7.8:46655
java.io.IOException: Can't assign requested address
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.jgroups.protocols.MPING.sendMcastDiscoveryRequest(MPING.java:286)
at org.jgroups.protocols.PING.sendDiscoveryRequest(PING.java:63)
at org.jgroups.protocols.PING.findMembers(PING.java:31)
at org.jgroups.protocols.Discovery.invokeFindMembers(Discovery.java:217)
at org.jgroups.protocols.Discovery.findMembers(Discovery.java:244)
at org.jgroups.protocols.Discovery.down(Discovery.java:387)
at org.jgroups.protocols.MERGE3$InfoSender.run(MERGE3.java:412)
at org.jgroups.util.TimeScheduler3$Task.run(TimeScheduler3.java:328)
at org.jgroups.util.TimeScheduler3$RecurringTask.run(TimeScheduler3.java:362)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:831)
@tsegismont提供了有效的答案。https://gist.github.com/rafaeltuelho/208568668e4205bd9b93
为224.0.0.1-231.255.255.254添加组播路由:
sudo route add -net 224.0.0.0/5 127.0.0.1
为232.0.0.1-239.255.255.254添加组播路由
sudo route add -net 232.0.0.0/5 192.168.1.3
对于230.0.0.0,我绑定到192.168.1.3