如何解决通过 paho js 客户端进行身份验证
我在我的项目中使用了 paho js 客户端而没有身份验证选项。但现在我需要添加它。很简单,就像这样:
var websocketclient = {
'client': null,'message': [],'subscriptions': [],'clientId': document.getElementById('clientid').value,'status': [],'connected': false,'connect': function() {
var host = "127.0.0.1";
var port = 8083;
var clientId = websocketclient.clientId;
var reconnectTimeout = 2000;
this.client = new Paho.MQTT.Client(host,port,clientId);
var options = {
timeout: 3,onSuccess: this.onConnect.bind(this),onFailure: this.onFailure,userName: "username",password: "password"
};
this.client.onMessageArrived = this.onMessageArrived;
this.client.onConnectionLost = this.onConnectionLost;
this.client.connect(options);
},...........
};
但我不确定如何对密码保密。有什么方法吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。