Quectel bc660 k-gl Unauthorized

Hello,
i’m using the free hiveMQ cloud edition. I want to connect my quectel bc660 k-gl with the broker. I can receive the ACK from the server but when i try to connect i get this: Connection Refused: Unauthorized.

Can someone tell me why? In the access manager i set up two users and both are getting the same errorcode.
I also tried to use an CA certificate (which works fine with my laptop) but also unauthorized.

I dont know what to do…

Hello Felix,

It is great that you are interested in MQTT, please be welcome in our community!

Your MQTT Client receives the CONNACK so this is not a certificate issue. “Unauthorised” response indicates that username or password is wrongly encoded.

What MQTT Client library are you using with your device? Can you show us your code that connects to the MQTT Broker?

Thanks,
Dasha from HiveMQ Team

Hello Dasha,
I’m not using a library. After everything is initialiezed i just have this “switch case” which goes to the next step when the button is pressed.

The AT commands are from the quectel bc660k-gl mqtt notes.

switch(button_counter)
{
//disable sleepmode
  case 1:
printf("AT+QSCLK\r\n");
quectel_send("AT+QSCLK=0",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
once=0;
break;
//put ca cert to quectel
  case 2:
printf("AT+QSSLCFG\r\n");
quectel_send("AT+QSSLCFG=0,0,\"cacert\"",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
err=quectel_get_unsolicited(QUECTEL_WAIT,2000);

for (int p=0;p<strlen(cert);p++)
{
 uart2_putc(cert[p]);
}
 uart2_putc('\032');

err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
once=0;
break;
// enable ssl
   case 3:
printf("AT+QMTCFG=\"ssl\"");
quectel_send("AT+QMTCFG=\"ssl\",0,1,0,0",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
once=0;
break;
//set mqtt version to 3.1.1
   case 4:
printf("AT+QMTCFG=\"version\"");
quectel_send("AT+QMTCFG=\"version\",0,1",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
once=0;
break;
//open hivemq cloud
  case 5:
printf("AT+QMTOPEN");
quectel_send("AT+QMTOPEN=0,\"7da17e617ce348f0844f3e2df7bec2d0.s2.eu.hivemq.cloud\",8883",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
err=quectel_get_unsolicited(QUECTEL_WAIT,15000);
printf("\r\nStatus %s\r\n", buf);
once=0;
break;
//connect with hiveMq broker
   case 6:
printf("AT+QMTCONN");
quectel_send("AT+QMTCONN=0,\"xxx\",\"xxx\",\"xxx\"",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_1S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
err=quectel_get_unsolicited(QUECTEL_WAIT,15000);
printf("\r\nStatus %s\r\n", buf);
once=0;
break;
//publish test message
   case 7:
printf("AT+QMTPUB");
quectel_send("AT+QMTPUB=3,0,0,0,\"test/topic\",5,\"test\"",QUECTEL_BLOCKING);
err=quectel_get_response(QUECTEL_TIMEOUT_5S);
buf=quectel_get_recbuf();
printf("\r\nStatus %i\r\n%s\r\n",err, buf);
once=0;
break;
default: break;

}

answer to AT+QMTOPEN: +QMTOPEN: 0,0 (succesful)
answer to AT+QMTCONN: +QMTCONN: 0,0,5 (sent packet successfully and received an ACK from server, Connection refused: Unauthorized)
and of course when i try to publish something after that message i get an error…

what could be the problem with my password and username?
I just wrote them into the “xxx” fields as i wrote them in the access manager.

Thank you and Best Regards

Felix

Anyone who has an idea to solve the issue?

Hello Felix,

Your devices actually makes the connection but it is Not Authorised by the broker (CONN ACK response code 5 indicates that).

The problem with username and password usually is the encoding. While username is a UTF-8 string, the password is an array of bytes. While some libraries are converting the password string into bytes correctly, other libraries don’t do that. Hence the “Unauthorised” response code.

Kind regards,
Dasha from HiveMQ Team

Hello,
I am facing the same problem with my Quectel module.

Did you find a solution for the +QMTCONN: 0,0,5 problem ?

Thanks

Hi @nofan ,

Please check if you have TLS-SNI extension available and used:

Hi @Daria_H I have enables SNI on TLS but the problem is still there