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

Fix NoRouteToHost exception in UDP._send()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.6.18, 2.11.1, 2.12
    • None
    • None
    • Low
    • Hide

      Disable the NIC and re-enable it (works on Fedora, doesn't seem to work on Windows only)

      Show
      Disable the NIC and re-enable it (works on Fedora, doesn't seem to work on Windows only)

      We did the same test with Weblogic and it is able to reconnect after a network failure.

      I had a quick look at the code of JGroups and I think that we can override this limit by a minor modification. It is not necessary to recreate a socket in case of the raise of an NoRouteToHostException, we can bind the socket to the interface. I've modified the code to catch the NoRouteToHostException and now my cluster works well and JBoss and reconnect properly.

      I've modified the _send method of UDP class like this :
      org.jgroups.protocols.UDP._send :

      private void _send(InetAddress dest, int port, boolean mcast, byte[] data, int offset, int length) throws Exception {
      DatagramPacket packet=new DatagramPacket(data, offset, length, dest, port);
      try {
      if(mcast) {
      if(mcast_send_sockets != null) {
      MulticastSocket s;
      for(int i=0; i < mcast_send_sockets.length; i++) {
      s=mcast_send_sockets[i];
      try

      { s.send(packet); }

      // solve reconnection issue with Windows
      catch(NoRouteToHostException e)

      { log.warn(e.getMessage() +", reset interface"); s.setInterface(s.getInterface()); }

      catch(Exception e)

      { log.error("failed sending packet on socket " + s); }

      }
      }
      else { // DEFAULT path
      if(mcast_sock != null) {
      try

      { mcast_sock.send(packet); }

      // solve reconnection issue with Windows
      catch(NoRouteToHostException e)

      { log.warn(e.getMessage() +", reset interface"); mcast_sock.setInterface(mcast_sock.getInterface()); }

      }
      }
      }
      else

      { if(sock != null) sock.send(packet); }

      }
      catch(Exception ex)

      { throw new Exception("dest=" + dest + ":" + port + " (" + length + " bytes)", ex); }

      }

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

                Created:
                Updated:
                Resolved: