[URGENT] RE: Request for Support – Intermittent IoT Device Connection to Azure IoT Hub

CEPE Energia 5 Pontos de reputação
2025-11-06T10:39:00.67+00:00

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:

  • Device ID: dispositivo_beta01-4G
  • Host name: REDACTED__.azure-devices.net__
  • Microsoft Account: ******@outlook.com__

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

Azure IoT Central
Azure IoT Central

Uma plataforma de aplicativo de IoT (Internet das Coisas) hospedada no Azure.

0 comentários Sem comentários

2 respostas

Classificar por: Mais Antigo
  1. Manas R Mohanty 17,270 Pontos de reputação Moderador
    2025-11-06T18:39:19.09+00:00

    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.




    Esta resposta foi útil?


  2. CEPE Energia 5 Pontos de reputação
    2025-11-13T12:34:14.1166667+00:00

    20251110 Log ConectaAzure - conn_and_discon.txt

    Follow attached the Log file as requested.

    Esta resposta foi útil?

    1 pessoa achou esta resposta útil.
    0 comentários Sem comentários

Sua resposta

As respostas podem ser marcadas como ‘Aceitas’ pelo autor da pergunta e ‘Recomendadas’ pelos moderadores, o que ajuda os usuários a saber a resposta que resolveu o problema do autor.