Arduino 如何使用错误的凭据连接到mqtt服务器?

Arduino 如何使用错误的凭据连接到mqtt服务器?,arduino,mqtt,nodemcu,Arduino,Mqtt,Nodemcu,我在arduino中为mqtt服务器提供了错误的凭据,但我仍然能够连接到mqtt服务器并从nodemcu板接收消息。 代码如下: const char* mqttserver="broker.mqtt-dashboard.com"; const char* clientid="clie"; //client1 const char* username="sampleCli"; //sampleclient const char* password="clien"; //client123

我在arduino中为mqtt服务器提供了错误的凭据,但我仍然能够连接到mqtt服务器并从nodemcu板接收消息。 代码如下:

const char* mqttserver="broker.mqtt-dashboard.com";
 const char* clientid="clie"; //client1
 const char* username="sampleCli"; //sampleclient
 const char* password="clien"; //client123
我给错了clientid以及用户名和密码。我使用mqtt-box作为mqtt代理

以下是连接到mqtt代理的代码

if(client.connect(clientid,username,password))
{
  Serial.println("connected");
  client.publish("topic1","connected");
}
else
{
  Serial.println("failed to connect");
  Serial.print(client.state());
  delay(5000);
}
我无法在串行监视器中获取任何“连接失败”语句,mqtt代理也会从nodemcu板接收消息。
我犯了什么错误

我的猜测是,您的服务器设置没有正确要求密码

尝试使用类似的方法来确认服务器的行为符合预期,然后重试客户端代码