This is because there are multiple network interfaces in my macOS, both for 
ipv4 and ipv6:

```
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether e0:ac:cb:7f:75:20
        inet6 fe80::cfb:9054:967d:13be%en0 prefixlen 64 secured scopeid 0x5
        inet 192.168.31.235 netmask 0xffffff00 broadcast 192.168.31.255
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
        ether 62:32:71:46:6b:2e
        inet6 fe80::6032:71ff:fe46:6b2e%awdl0 prefixlen 64 scopeid 0x7
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active
```

`awdl0` is ipv6 only and `en0` is both ipv4 and ipv6 available. However the JVM 
selects `awdl0` as the default Network Interface in 
`java.net.DefaultInterface#getDefault()` method.  So if we use a ipv4 address 
for multicasting, the error will occur.

If `-Djava.net.preferIPv4Stack=true` is specified, JVM will avoid choosing 
`awdl0` as default network interface. So everything will be all right.

### Enhancement

Basically we don't want to let user to specify that vm args manually, so I'd 
like to propose to automatically select network interface by the input 
multicast address.

If the multicast address is ipv4 address, automatically use ipv4 network 
address (by calling `java.net.MulticastSocket#setInterface()`), and vise versa.
 



[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/2423 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to