Hi ChrisIn  macOS test server, when configuring the mcastBindAddress as 
192.168.1.139 and address as 228.0.0.4 , the code does not use mcastBindAddress 
, instead it uses multicast  address for socket binding and throws exception 
when sending the datagram packet. Here is the exception:
Exception in thread "main" org.apache.catalina.tribes.ChannelException: 
java.io.IOException: Can't assign requested address (sendto failed); No faulty 
members identified.
    at 
org.apache.catalina.tribes.group.ChannelCoordinator.internalStart(ChannelCoordinator.java:207)
    at 
org.apache.catalina.tribes.group.ChannelCoordinator.start(ChannelCoordinator.java:111)
    at 
org.apache.catalina.tribes.group.ChannelInterceptorBase.start(ChannelInterceptorBase.java:165)
    at 
org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.start(MessageDispatchInterceptor.java:228)
    at 
org.apache.catalina.tribes.group.ChannelInterceptorBase.start(ChannelInterceptorBase.java:165)
    at 
org.apache.catalina.tribes.group.GroupChannel.start(GroupChannel.java:483)
    at test.MemberShipTest.main(MemberShipTest.java:44)
Caused by: java.io.IOException: Can't assign requested address (sendto failed)
    at java.net.PlainDatagramSocketImpl.send(Native Method)
    at java.net.DatagramSocket.send(DatagramSocket.java:693)
    at 
org.apache.catalina.tribes.membership.McastServiceImpl.send(McastServiceImpl.java:505)
    at 
org.apache.catalina.tribes.membership.McastServiceImpl.send(McastServiceImpl.java:482)
    at 
org.apache.catalina.tribes.membership.McastServiceImpl.start(McastServiceImpl.java:268)
    at 
org.apache.catalina.tribes.membership.McastService.start(McastService.java:289)
    at 
org.apache.catalina.tribes.group.ChannelCoordinator.internalStart(ChannelCoordinator.java:196)
    ... 6 more
When I changed the address to mcastBindAddress while creating the socket, no 
more exception occurred.Regards.Gurkan
    On Thursday, May 30, 2019, 5:56:46 PM GMT+3, Christopher Schultz 
<ch...@christopherschultz.net> wrote:  
 
 -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Gurkan,

On 5/29/19 02:28, Gurkan Erdogdu wrote:
> Hi In an McastServiceImpl#setupSocket method, if the user
> configures the mcastBindAddress, it will use the socket to bind to
> this address. But, in the code below, it uses the "address" field
> while creating the socket. Is this correct ?
> 
> if (mcastBindAddress != null) { try { 
> log.info(sm.getString("mcastServiceImpl.bind", address, 
> Integer.toString(port))); socket = new MulticastSocket(new 
> InetSocketAddress(address,port)); } catch (BindException e) {

That definitely does look weird.

The constructor for McastServiceImpl is even more strange:

    /**
    * @param bind - the bind address (not sure this is used yet)
    * @param mcastAddress - the mcast address
    */
    public McastServiceImpl([...],
        InetAddress bind,
        InetAddress mcastAddress,
        [...])
    throws IOException {
        [...]
        this.address = mcastAddress;
        this.mcastBindAddress = bind;
        [...]
    }

There are two items, here:

1. An address to bind to (locally)
2. A multicast target address

The constructor takes these two and calls them:

1. bind
2. mcastAddress

But the class members are called:

1. mcastBindAddress
2. address

The mcastBindAddress appears to be ignored in all but one place, where
the socket's interface is changed to it at McastServiceImpl.java:223:

220    if (mcastBindAddress != null) {
221        if(log.isInfoEnabled())
222            log.info(sm.getString("mcastServiceImpl.setInterface",
mcastBindAddress));
223        socket.setInterface(mcastBindAddress);
224    } //end if

I don't know enough about multicast to know what is supposed to be
happening, here. AFAIK, mcast is a broadcast mechanism and so there is
no difference between the "target" address and the "bind" address: you
just throw packets at the interface:port and that's that.

The code could probably use some clean-up, or at least some better
in-code documentation by someone who has a good understanding of the
whole situation.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlzv7ysACgkQHPApP6U8
pFjuNg/8DkSdnsKkoTmGS1N37IXVcdj5cyHlmPC+BdP3NWE4oky0j5uFrGUqcaRG
UJLsPMvtZwgSaQ/wxgin4maluAmK77Agt76r6tXJNbbpdglXVyz7ONWO8a5xmk9R
ltqLWnHVw4a/HB5vatxFgqWWc6L1qWnocJL7/sWUn1M9y9Ee43/+h5OYnaBn9bCM
R1jqVhZAodC2k1eD3HXedCMaVIA4k2fZF+TteOHNu2rDr01mJVZzPjNJ/zy4sNg7
L0P0uuqCp3ylh563c3t+slL/9XFoVDNytD46qJlmDDcOYczNjf5An6dyWBJEX348
d0FdWOw5h45lJKhMd1L9WNLymxj3gQ9a3okfhiEqyunsZA4SbMNCPgy4an8tzBsd
HsX1dNgD6P8aoy2umG6SvqgAoPb0mZxlVVT1NdbXN0uybdv/mUJgjDHNsbaCYOxG
UNBfT/p5VQxURhRuNqHsFYvHtA6pxt8mZBbwsHC6b/uOYgPXPrLbM4oQztF2YEzI
RDOr2kmA+JbEj5qKOeQa3BVGT5bUeLRWH+fDFiXq6ubdBdvHAifPJyGdYgAFLvZq
jm85WJJeNvluwB602JUJ/FFxCYe6sKL7jaqfZJClqZrscUDxve0Fckh9xLrQ/il2
0W1VqfxuWeFL6P0SgJOr7aZxbdA293o1/X10E9o6sMuWoCtHfk8=
=jSBA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

  

Reply via email to