Search code examples
javascriptangularjshtmlkaazing

Kaazing, AngularJS & BasicChallengeHandler


I'm trying to use the Kaazing Library in our HTML5 client. I already implemented it in a java client and it worked. It seems that there is a problem with the LoginHandler. When I debug the code it ends in a endless loop in the LoginHandler. The line callback(new PasswordAuthentication(usr, pwd)) is called over and over again:

// Configure a Basic Challenge Handler
var basicHandler = new BasicChallengeHandler();
  basicHandler.loginHandler = function(callback) {
  callback(new PasswordAuthentication(usr, pwd));
}

JmsConnectionProperties jmsProps = new JmsConnectionProperties();
jmsProps.connectionTimeout = 1000000;
jmsProps.reconnectAttemptsMax = -1;
jmsProps.reconnectDelay = 3000;
jmsProps.shutdownDelay = 5000;

console.log("Connect to: " + url);

// Create Connection Factory
jmsConnectionFactory = new JmsConnectionFactory(url, jmsProps);
websocketFactory = jmsConnectionFactory.getWebSocketFactory();
websocketFactory.setChallengeHandler(basicHandler);

// reate Connection future handler for the result
try {
    if (connection == null) {
        var connectionFuture = jmsConnectionFactory.createConnection( function() {
            try {
                // never comes to this line!!!
                connection = connectionFuture.getValue();
                // DO SOME STUFF

                    } catch (e) {
                        console.dir(e);
                        // alert(e.message);
                    }
                });
            } else {
                try {
                    connection.close(function() { /* Closed */
                    });
                } finally {
                    connection = null;
                }
            }
        } catch (ex) {
            console.dir(ex);
        }

Any help would be very appreciated!

Regards Angela


Solution

  • Is it possible that the username and password combination is incorrect, so that the client is being re-challenged?