Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2754

TUNNEL fails with bind exception when bind_port != 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.3.2, 5.2.21
    • None
    • None
    • False
    • None
    • False

      When TUNNEL.bind_port is set to a value != 0, then starting more than one member on the same host fails with a bind exception on the second and subsequent member:

      Exception in thread "main" java.net.BindException: Address already in use
      	at java.base/sun.nio.ch.Net.bind0(Native Method)
      	at java.base/sun.nio.ch.Net.bind(Net.java:565)
      	at java.base/sun.nio.ch.DatagramChannelImpl.bindInternal(DatagramChannelImpl.java:1267)
      	at java.base/sun.nio.ch.DatagramChannelImpl.bind(DatagramChannelImpl.java:1237)
      	at java.base/sun.nio.ch.DatagramSocketAdaptor.bind(DatagramSocketAdaptor.java:111)
      	at java.base/java.net.DatagramSocket.createDelegate(DatagramSocket.java:1425)
      	at java.base/java.net.DatagramSocket.<init>(DatagramSocket.java:328)
      	at java.base/java.net.DatagramSocket.<init>(DatagramSocket.java:387)
      	at org.jgroups.util.DefaultSocketFactory.createDatagramSocket(DefaultSocketFactory.java:116)
      	at org.jgroups.protocols.TUNNEL.init(TUNNEL.java:180)
      	at org.jgroups.stack.ProtocolStack.initProtocolStack(ProtocolStack.java:806)
      	at org.jgroups.stack.ProtocolStack.setup(ProtocolStack.java:442)
      	at org.jgroups.JChannel.init(JChannel.java:894)
      	at org.jgroups.JChannel.<init>(JChannel.java:124)
      	at org.jgroups.JChannel.<init>(JChannel.java:105)
      	at org.jgroups.demos.Chat.start(Chat.java:34)
      	at org.jgroups.demos.Chat.main(Chat.java:106)
      

      The reason is that TUNNEL creates a datagram socket for a unique address, but tries to bind to the same port.
      Solution: use one of the methods which increment the port until a free port is found to create the datagram socket. Check if requiring a unique address is still needed...

      Config {tunnel.xml}} attached to reproduce

            rhn-engineering-bban Bela Ban
            rhn-engineering-bban Bela Ban
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: