Google Cloud IoT Core - JWT Refresh

  1. My goal is:

Refresh JWT with Mongoose OS before timeout without disconnecting to IoT Core.

  1. My actions are:

Using MOS GCP Lib to connect to IoT Core.

  1. The result I see is:

MOS console:
mgos_gcp.c:86 Dropping MQTT connection due to imminent token expiration

On IoT Core I get this error with every timeout:

IoT Core logs:

 jsonPayload: {
  disconnectType: "SERVER"   
  eventType: "DISCONNECT"   
  protocol: "MQTT"   
  resourceName: "projects/..."   
  serviceName: ""   
  status: {
   code: 9    
   description: "FAILED_PRECONDITION"    
   message: "The connection broke or was closed by the client."    
  1. My expectation & question is:

The device should stay connected to IoT Core. The disconnection results in a loss of data if, for example, data is to be sent via commands. Is it possible to refresh the token without a disconnect?


Looks like this was intentionally added:

Unfortunately it’s not possible to get around this due to the token being sent when the initial connection is made, so it has to create a new connection, so at a minimum it would have to be handled immediately after the disconnect, but i havent’ dug into it to see for sure


I came across it afterwards. Apparently it was integrated to solve this problem until it reappeared.

Google talks about how to reconnect without “disconnecting” a device:

I’m currently not sure where to see the issue. If refreshing is only possible by reconnecting (disconnet followed by a connect), why does GCP issue an error message?