emqx版本:开源版5.1
操作系统:centos 8
php版本:7.4
php-mqtt/client版本:1.8
emqx后台-》访问控制-》客户端认证   使用的是Password-based认证方式(内置数据库),然后添加用户名 test1  密码 123456
使用mqttx客户端能正常连接,使用php-mqtt连接失败,报错信息:”[6] Establishing a connection to the MQTT broker failed: The configured broker responded with unauthorized.“
但是禁用掉Password-based的认证方式,php-mqtt能连接成功。
php代码如下:
$connectionSettings  = new ConnectionSettings();
$connectionSettings
->setUsername(‘test1’)
->setPassword(‘123456’)
->setKeepAliveInterval(60);
    $mqtt = new MqttClient($this->config['server'], $this->config['port'], $clientId);
    $mqtt->connect($connectionSettings, $this->config['clean_session']);
    $mqtt->publish($topic, json_encode($payload), $qos, $retain);
    $mqtt->disconnect();
不知道是哪里没搞对。。。求大神帮忙看下,谢谢!
 
        
