2017-04-10 1201 views
1

與用戶名連接時出現paho java客戶端的問題&密碼?Paho java客戶端連接失敗:用戶名或密碼不正確(4)

從paho JS客戶端它工作,但從Java客戶端它沒有。 我有這樣的代碼

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(); 
    } 
}); 

我得到這個例外

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([email protected]:50741): Username 'undefined' login failed for username_or_password_undefined 
06:47:36.463 [error] Client([email protected]:50742): Username 'undefined' login failed for username_or_password_undefined 

據泛美衛生組織文檔公共無效setPassword(的char []密碼),所以我在這裏路過的char []作爲paasword

我正在使用emqttd經紀商

回答

0

paho java客戶端連接用戶名時出現問題& 密碼?

nop。沒有,看起來您的用戶名和密碼不在代理的CAL中,您需要驗證您的身份驗證憑證是否正常。

和經紀人有ACL

相關問題