Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12951

Camel-AHC-WS: reconnect exception is not passed to exception handler

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.22.2
    • Fix Version/s: 2.24.0
    • Component/s: camel-ahc-ws
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      When WsEndPoint reconnect-method fails in line 172 to create connection it throws an exception which is logged but it should also be given to exception handler.

      This kind of situation happens when server is shut down while connection is open. First client tries to reconnect but when reconnect fails, client stops trying.

      I'm trying to implement a feature which tries continuously to reconnect to server when the server is down. Connection state (open, disconnected or trying to connect) should also be indicated.

      If exception is passed to exception handler then it would be possible to register exception handler outside Camel. The purpose of this exception handler is to shut down Camel context and recreate it again in order to reconnect. With this kind of setup I can continuously try to reconnect and also figure out the current connection state.

       

      https://github.com/apache/camel/blob/master/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java

       

      @Override
      public void onClose(WebSocket websocket, int code, String reason) {
         LOG.debug("websocket closed - reconnecting");
         try {
            reConnect();
         } catch (Exception e) {
            LOG.warn("Error re-connecting to websocket", e);
         }
      }
      

       

        Attachments

          Activity

            People

            • Assignee:
              acosentino Andrea Cosentino
              Reporter:
              jukka.aalto Jukka Aalto
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: