0 Replies Latest reply: Nov 7, 2018 9:18 AM by Johan RSS

    Example of VIRL tracker web sockets client



      Utilizing the API call /simengine/rest/tracking I have authorized a new tracker.  However when I attempt to connect to the URL of the web socket I get the error that I have not supplied a valid token.  How, and in what format, is VIRL expecting the token to be passed?  This is the snippet of code that I am testing with:

          public void run() {
              LOGGER.info("VirlTracker running");
              while (!shutdown) {
                  try {
                      VirlComms comms = new VirlComms(InetAddress.getByName("X.X.X.X"), 19399, "XXXXX", "XXXXXX");
                      JsonObject trackerinfo = comms.requestJSONData(VirlComms.RequestType.POST, "/tracking", "tracking", null);
                      url = trackerinfo.get("url").getAsString();
                      token = trackerinfo.get("token").getAsString();
                      LOGGER.info("Creating WebSocket container");
                      WebSocketContainer container = ContainerProvider.getWebSocketContainer();
                      url = url+"?ws_token="+token;
                      LOGGER.info("Connecting to "+url+" with token "+token);
                      session = container.connectToServer(this, URI.create(url));
                      LOGGER.info("VirlTracker still running");
                  } catch (InterruptedException e) {
                      LOGGER.info("VirlTracker interrupted: " + e.getMessage());
                      shutdown = true;
                  } catch (Exception e) {
                      LOGGER.info("VirlTracker Exception "+e);
                      shutdown = true;