3 Replies Latest reply on Sep 16, 2017 5:54 AM by ctomc

    Issues with Native Client

    rwlarsen

      I am attempting to read a portion of the Wildfly config from within a deployed application.  I'm following the documentation found here:

      https://docs.jboss.org/author/display/WFLY10/The+native+management+API

      Wildfly will not start with the line (from the documentation):

      <native-interface interface="management" port="9999" security-realm="ManagementRealm"/>

      in <management><managemeent-interfaces> as the "interface" and "port" attributes aren't recognized.  I've replaced that with:

      <native-interface security-realm="ManagementRealm">

          <socket-binding native="management-native"/>

      </native-interface>

      and added

      <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>

      to <socket-binding-group>.

       

      Wildfly seems happy with this configuration, and starts without error, and is listening on port 9999.

       

      However the client is not able to connect:

      java.net.ConnectException: JBAS012144: Could not connect to remote://hostname.local:9999. The connection timed out

       

      The code being executed is based on the code in the documentation:

       

              final CallbackHandler handler = (Callback[] callbacks) -> {

                  for (Callback cb : callbacks) {

                      if (cb instanceof NameCallback) {

                          NameCallback ncb = (NameCallback) cb;

                          ncb.setName("username");

                      } else if (cb instanceof PasswordCallback) {

                          PasswordCallback pwcb = (PasswordCallback) cb;

                          pwcb.setPassword("password".toCharArray());

                      } else if (cb instanceof RealmCallback) {

                          RealmCallback rcb = (RealmCallback) cb;

                          rcb.setText("ManagementRealm");

                      } else {

                          throw new UnsupportedCallbackException(cb);

                      }

                  }

              };

              try (ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9999, handler)) {

                  final ModelNode op = new ModelNode();

                  op.get("operation").set("read-resource");

                  ModelNode address = op.get("address");

                  address.set("subsystem", "keycloak");

                  op.get("recursive").set(true);

                  final ModelNode result = client.execute(op);

                  if (Operations.isSuccessfulOutcome(result)) {

                      System.out.println(result.get("result").toString());

                  } else {

                      throw new RuntimeException(Operations.getFailureDescription(result).asString());

                  }

              }

       

      The relevant portion of the pom is:

              <dependency>

                  <groupId>org.jboss.as</groupId>

                  <artifactId>jboss-as-controller-client</artifactId>

                  <version>7.2.0.Final</version>

              </dependency>

       

      I'm not sure if this is an issue with the config or with the code, since I cannot get a connection at all.  Any help would be greatly appreciated.

        • 1. Re: Issues with Native Client
          ctomc

          Docs needs to be updated a bit. Native mgmt protocol is now done via http-upgrade, as such port changed.

           

          see Management Clients - WildFly 10 - Project Documentation Editor

          how to use http upgrade enabled mgmt client

          https://docs.jboss.org/author/display/WFLY10/The+HTTP+management+API

          for the client code itself, you would need to use different protocol.

           

          something like this:

           

          try (ModelControllerClient client = ModelControllerClient.Factory.create("http-remoting", "localhost", 9990)){

          ...

           

          dependency wise you should be using dependencies from same version of server you are connecting to (or newer)

          You are using ones from 7.2 for connecting to WildFly 10. that wont work.

          this should do it:

          <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-controller-client</artifactId>
            <version>2.1.0.Final</version>
          </dependency>

          1 of 1 people found this helpful
          • 2. Re: Issues with Native Client
            rwlarsen

            Thanks, that seems to have resolved everything.

             

            Is there some way for me to submit changes to the docs to help keep them, more up to date?

            • 3. Re: Issues with Native Client
              ctomc

              I've updated our docs already.

              but for contribution our current confluence docs infrastructure is bit hard to work with.

               

              We are moving to ascidoc based documentation in following weeks, and starting wildfly 12 dev cycle everything will be in git.

               

              This is current state of "new" docs GitHub - ctomc/docs-playground  if you want you can send PR, I will make sure it is merged before it gets to wildfly master branch.

              this is how renedered stuff looks like WildFly Admin Guide

               

              just keep in mind that this is still work in progress.