Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] (no subject)


Is there some issue with java client when connecting with username & password ???

paho JS client it works but from java client it doesn't.
I have this code

    MqttConnectOptions conOpt = new MqttConnectOptions();
    conOpt.setCleanSession(false);
    conOpt.setUserName("test5");
    conOpt.setPassword("123".toCharArray());
    MqttDefaultFilePersistence filePersistence = new MqttDefaultFilePersistence("/home/manish/Downloads/mqttPersist");
    client = new MqttAsyncClient(appProps.getProperty("mqtt.broker"),
            appProps.getProperty("mqtt.clientId"), filePersistence);
    client.setCallback(this);
    client.connect(conOpt, new IMqttActionListener() {
        @Override
        public void onSuccess(IMqttToken imt) {
            try {
                client.subscribe(Constants.INTERNAL_TOPICS, Constants.INTERNAL_TOPIC_QOS);
            } catch (MqttException ex) {
                ex.printStackTrace();
            }
        }

        @Override
        public void onFailure(IMqttToken imt, Throwable thrwbl) {
            thrwbl.printStackTrace();
        }
    });

i am getting this exception

Bad user name or password (4)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:28)
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:885)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118)
at java.lang.Thread.run(Thread.java:745)

emqt console

06:47:36.456 [error] Client(notification_subs_bot@127.0.0.1:50741): Username 'undefined' login failed for username_or_password_undefined
06:47:36.463 [error] Client(notification_subs_bot@127.0.0.1:50742): Username 'undefined' login failed for username_or_password_undefined

According paho documentation public void setPassword(char[] password) So here i am passing char[] as paasword

--
Thanks,
Manish Kumar

Back to the top