Uma plataforma de aplicativo de IoT (Internet das Coisas) hospedada no Azure.
20251110 Log ConectaAzure - conn_and_discon.txt
Follow attached the Log file as requested.
Não há mais suporte para esse navegador.
Atualize o Microsoft Edge para aproveitar os recursos, o suporte técnico e as atualizações de segurança mais recentes.
Dear Microsoft Azure Support Team,
I am reaching out to kindly request your assistance in identifying the exact cause of an intermittent connection issue between my IoT device and the Azure IoT Hub.
I am currently developing firmware for a board called LilyGo, which includes an ESP32-WROVER microcontroller and a SIMCOM A7670SA modem.
At the moment, for example, the device is successfully connected; however, at any given time, the modem disconnects unexpectedly. Even if I revert to the original firmware code (without any modifications), the modem often fails to reconnect afterward.
My initial suspicion is that the issue may be related to the SAS token expiration, but after conducting several tests — generating new tokens and attempting reconnection — all attempts have failed.
To give you an idea, I haven’t changed a single line of code since last Friday, and today, after simply updating the SAS token, the board connected successfully again. At this moment, the modem is connected and functioning normally.
Do you understand what might be happening? For some reason, the modem suddenly loses connection and is unable to reconnect for a period of time. Then, after a few days, it reconnects successfully without any code changes.
I need to understand what is causing this behavior. My impression is that the IoT Hub, after a few failed connection attempts, starts rejecting further connections from the device, reporting a connection failure — even when using a valid, non-expired SAS token.
Could you please help me understand what is happening and how I can resolve this issue?
Device Information:
P.S.: Attached to this message are two logs to help analyze the issue: the first shows a successful connection, and the second shows an unsuccessful connection after the modem disconnects and is unable to reconnect, even when reverting to the original firmware code. Thank you very much for your support.
Best regards, Kopelvski A. M.
20251031 Log ConectaAzure20251031 Log ConectaAzure - COMErros.txt - semErros.txt
Note: Observação: Email e nome do host foram removidos no lado do suporte
Uma plataforma de aplicativo de IoT (Internet das Coisas) hospedada no Azure.
20251110 Log ConectaAzure - conn_and_discon.txt
Follow attached the Log file as requested.
Ola' CEPE Energia
Aqui está a análise e a recomendação com base nos logs.
Sessão bem-sucedida — 20251031 Log ConectaAzure - semErros
PDP e IP estabelecidos (+NETOPEN, +IPADDR: 10.9.181.240).
Sincronização de horário via NITZ (offset -12).
Contexto TLS configurado (sslversion=4, authmode=0). Configurações de SNI/hostname retornam ERROR, mas a sessão continua.
Conexão MQTT com token SAS bem-sucedida: +CMQTTCONNECT: 0,0, seguida de publicações com PUBACK repetidos. [20251031 L…- semErros | Txt]
Sessão com falha — 20251031 Log ConectaAzure - COMErros
Bring-up de rede semelhante; sincronização via NITZ (offset -12).
Contexto TLS igual ao anterior; SNI/hostname ainda retornam ERROR.
Conexão MQTT falha durante TLS: +CMQTTCONNECT: 0,31 seguido de ERROR e mensagem “Falha em CMQTTCONNECT (handshake TLS)”. [20251031 L…- COMErros | Txt]
Informações do dispositivo
O dispositivo é ESP32-WROVER + SIMCom A7670SA, conectando-se a CEPEHub.azure-devices.net com ID dispositivo_beta01-4G. Relata falhas intermitentes de reconexão após desconexões, suspeitando de token SAS ou rejeição pelo Hub. [learn.microsoft.com]
Causa provável (e por que parece intermitente)
Incompatibilidade de handshake TLS/cifra no modem O Azure IoT Hub aplica TLS 1.2 + cifras fortes desde 31/08/2025. Muitos módulos celulares usam modos “auto” que podem tentar cifras não suportadas ou TLS 1.3, causando falhas esporádicas. O erro +CMQTTCONNECT: 0,31 indica falha no handshake TLS.
Confiança na CA raiz no modem O IoT Hub migrou para certificados DigiCert Global Root G2. Se o modem não tiver essa CA carregada (ou validação desativada via authmode=0), o comportamento do handshake pode variar.
SNI não configurado / não suportado O IoT Hub usa SNI para seleção de hostname. Logs mostram AT+CSSLCFG="sni",0,1 e AT+CSSLCFG="hostname",0,"CEPEHub.azure-devices.net" retornando ERROR.
Por isso parece “aleatório”: depende da rota da célula e combinações de cifra/SNI.
Plano passo a passo para solução
Objetivo: atender aos requisitos TLS 1.2 + DigiCert G2 do IoT Hub e seguir especificações MQTT.
A. Forçar TLS 1.2 no modem
Configure versão TLS para 1.2 apenas (não “auto”).
Ex.: AT+CSSLCFG="sslversion",0,(valor para TLS 1.2).
Ajuste timeout: AT+CSSLCFG="negotiatetime",0,60 e ignorelocaltime: AT+CSSLCFG="ignorelocaltime",0,1.
B. Carregar e usar DigiCert Global Root G2
Baixe e configure CA: AT+CCERTDOWN=cacert.pem AT+CSSLCFG="authmode",0,1 AT+CSSLCFG="cacert",0,"cacert.pem"
C. Habilitar SNI/hostname (ou atualizar firmware)
Comandos: AT+CSSLCFG="sni",0,1 AT+CSSLCFG="hostname",0,"CEPEHub.azure-devices.net"
D. Seguir requisitos MQTT do IoT Hub
Username: CEPEHub.azure-devices.net/dispositivo_beta01-4G/?api-version=2021-04-12
Password: token SAS renovado a cada reconexão.
Client ID = dispositivo_beta01-4G.
E. Estratégia de reconexão
Backoff exponencial (1s → 2s → 4s … máx. 1–2 min).
Sempre gerar novo token SAS.
cleanSession=1.
Espero que ajude.
Nota: Desculpe se encontrar alguma anomalia na tradução.
Obrigado.