Closed reubenmiller closed 1 year ago
I just checked the other plugins and they has the following state and logs:
plugin | JWT Successfully received |
---|---|
c8y-log-plugin | No |
c8y-configuration-plugin | No |
c8y-firmware-plugin | Yes |
Logs
# journalctl -fu c8y-log-plugin
-- Journal begins at Mon 2023-05-15 19:40:47 UTC. --
May 15 20:12:51 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:12:51.755599156Z INFO C8YJwtRetriever: send (0, Err(NoJwtReceived))
May 15 20:12:51 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:12:51.755842156Z INFO C8Y-REST => JWT: recv Some(Err(NoJwtReceived))
May 15 20:12:51 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:12:51.756224364Z ERROR c8y_http_proxy::actor: An error occurred while retrieving internal Id, operation will retry in 60 seconds
May 15 20:12:51 9b469091f733 c8y-log-plugin[77]: Error: CustomError("JWT token not available")
May 15 20:13:51 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:13:51.759196976Z INFO C8Y-REST => JWT: send ()
May 15 20:13:51 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:13:51.759262559Z INFO C8YJwtRetriever: recv Some((0, ()))
May 15 20:14:01 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:14:01.763226689Z INFO C8YJwtRetriever: send (0, Err(NoJwtReceived))
May 15 20:14:01 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:14:01.763307814Z INFO C8Y-REST => JWT: recv Some(Err(NoJwtReceived))
May 15 20:14:01 9b469091f733 c8y-log-plugin[77]: 2023-05-15T20:14:01.763322106Z ERROR c8y_http_proxy::actor: An error occurred while retrieving internal Id, operation will retry in 60 seconds
May 15 20:14:01 9b469091f733 c8y-log-plugin[77]: Error: CustomError("JWT token not available")
root@9b469091f733:/setup# journalctl -fu c8y-configuration-plugin
-- Journal begins at Mon 2023-05-15 19:40:47 UTC. --
May 15 20:12:51 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:12:51.754704031Z INFO C8YJwtRetriever: send (0, Err(NoJwtReceived))
May 15 20:12:51 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:12:51.754985656Z INFO C8Y-REST => JWT: recv Some(Err(NoJwtReceived))
May 15 20:12:51 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:12:51.755052406Z ERROR c8y_http_proxy::actor: An error occurred while retrieving internal Id, operation will retry in 60 seconds
May 15 20:12:51 9b469091f733 c8y-configuration-plugin[71]: Error: CustomError("JWT token not available")
May 15 20:13:51 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:13:51.759324392Z INFO C8Y-REST => JWT: send ()
May 15 20:13:51 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:13:51.759404309Z INFO C8YJwtRetriever: recv Some((0, ()))
May 15 20:14:01 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:14:01.763276814Z INFO C8YJwtRetriever: send (0, Err(NoJwtReceived))
May 15 20:14:01 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:14:01.763337772Z INFO C8Y-REST => JWT: recv Some(Err(NoJwtReceived))
May 15 20:14:01 9b469091f733 c8y-configuration-plugin[71]: 2023-05-15T20:14:01.763350731Z ERROR c8y_http_proxy::actor: An error occurred while retrieving internal Id, operation will retry in 60 seconds
May 15 20:14:01 9b469091f733 c8y-configuration-plugin[71]: Error: CustomError("JWT token not available")
root@9b469091f733:/setup# journalctl -fu c8y-firmware-plugin
-- Journal begins at Mon 2023-05-15 19:40:47 UTC. --
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.510676374Z INFO Runtime: Running MQTT-1
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511735083Z INFO Runtime: Running C8YJwtRetriever-2
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511741999Z INFO Runtime: Running Downloader-3
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511747874Z INFO Runtime: Running FirmwareManager-4
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511752166Z INFO Runtime: Running Timer-5
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511761833Z INFO Runtime: Running HealthMonitorActor-6
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.511780624Z INFO c8y-firmware-plugin: send Message { topic: Topic { name: "tedge/health/c8y-firmware-plugin" }, payload: "{"pid":72,"status":"up","time":1684179671}", qos: AtLeastOnce, retain: true }
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.512025333Z INFO c8y_firmware_manager::actor: Ready to serve firmware requests.
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.534127916Z INFO MQTT: recv Ok(Some(Message { topic: Topic { name: "tedge/health/c8y-firmware-plugin" }, payload: "{"pid":72,"status":"up","time":1684179671}", qos: AtLeastOnce, retain: true }))
May 15 19:41:11 9b469091f733 c8y-firmware-plugin[72]: 2023-05-15T19:41:11.534150999Z INFO MQTT: recv Ok(Some(Message { topic: Topic { name: "c8y/s/us" }, payload: "500", qos: AtLeastOnce, retain: false }))
After more debugging there is are some indications that the empty message is not being published to c8y/s/uat
.
I was able to manually publish a message via the command line to simulate the message and it was successful, though for it to work I did have to wait to send it at the correct time (when the service under test was actually subscribed to the c8y/s/dat
topic)
I used the following command to simulate an empty string.
mosquitto_pub -t c8y/s/uat -m ''
Some logging and retry logic regarding republishing to the c8y/s/uat
topic has been added. Closing for now. If it is viewed in the wild then it can be reopened.
Describe the bug
Sometimes on device startup, the
tedge-mapper-c8y
is stuck in the initialization loop requesting a JWT token. This blocks some of the communication going out from the device to Cumulocity, as the mapper requires a JWT to retreive information such as the internal device id of digital twin in Cumulocity.To Reproduce
Note: This bug is very difficult to reproduce because it does not occur every time!
The following instructions use the tedge-demo-container to setup thin-edge.io.
Download the docker compose file
Start the demo container
Bootstrap the device (it will prompt for input)
Open the UI to the device after it has been successfully bootstrapped
Send a "Restart Device" operation via the Cumulocity UI to the device
After the container has restarted, observer the journald logs for the
tedge-mapper-c8y
processOnce in this never ending retry loop, restarting the
tedge-mapper-c8y
multiple times (~5 times) has not affect. However restartingmosquitto
then thetedge-mapper-c8y
then worked.Expected behavior
The JWT connection should be reliable to ensure that the
tedge-mapper-c8y
service is able to function reliable communication with Cumulocity.Screenshots
Checking the log of the mapper showed that it was in a continous loop to request the JWT from Cumulocity (via the MQTT bridge).
The log snippet was obtained using the following command:
Log output
However I could still manually request a Cumulocity token via publishing to the MQTT topic
c8y/s/uat
using the following commands:The output of another console running
tedge mqtt sub '#'
shows that the token was being returned successfully.Environment (please complete the following information):
Additional context
Additional logs for
tedge-mapper-c8y
are available here:tedge-mapper-c8y.log
The mosquitto logs seem to show that there are clients sending the
c8y/s/dat
requests.