2 Replies Latest reply on Dec 9, 2013 6:32 PM by Savvas Andreas Moysidis

    Programmatic Endpoint issue in WildFly

    Savvas Andreas Moysidis Newbie



      I am trying to test the latest release of WildFly and have come across an issue with a programmatic endpoint. I am basically following the examples given in Danny Coward's book "Java WebSocket Programming" and in one of them a programmatic endpoint needs to be created similar to the following:


      import java.io.IOException;

      import java.util.logging.Level;

      import java.util.logging.Logger;


      import javax.websocket.CloseReason;

      import javax.websocket.Endpoint;

      import javax.websocket.EndpointConfig;

      import javax.websocket.MessageHandler;

      import javax.websocket.Session;

      import javax.websocket.server.ServerEndpoint;



      public class ProgrammaticLifecycleEndpoint extends Endpoint {


          private static final String START_TIME_SESSION_KEY = "Start Time";

          private static final String ILLEGAL_SEQUENCE = "xxx";

          private static final String CLOSE_REQUEST_COMMAND = "close";

          private Logger logger = Logger.getLogger("ProgrammaticLifecycleEndpoint");


          private Session session;



          public void onOpen(Session session, EndpointConfig endpConfig) {

              System.out.println("onOpen() invoked!");


              this.session = session;

              final Session mySession = session;

              this.session.addMessageHandler(new MessageHandler.Whole<String>() {


                  public void onMessage(String message) {

                      try {


                          if (message.contains(CLOSE_REQUEST_COMMAND)) {

                              sendMessage("1:Server closing after "

                                      + getConnectionSeconds() + "seconds");


                          } else {

                              sendMessage("3:Just processed a message");


                      } catch (IOException e) {






              session.getUserProperties().put(START_TIME_SESSION_KEY, System.currentTimeMillis());

              sendMessage("3:Just opened");





          public void onClose(Session session, CloseReason closeReason) {

              System.out.println("Connection closed!");




          public void onError(Session session, Throwable thr) {

              sendMessage("2:Error: " + thr.getMessage());



      // more code here


      I am able to make a GET request to the above endpoint, meaning I am getting a 101 response, which means that the endpoint is being mapped, but the onOpen() method doesn't seem to be getting called at all (my sys out message isn't getting printed and the ui doesn't react as expected).

      The annotation equivalent of the above code is working ok.


      Any ideas?


      I am using version 8.0.0.Beta1