Chirpstack Application : error:"invalid MIC"

Today, my application on chirpstack presented a curious problem. The messages on the application server have an error (“invalid MIC”) like image [1] I was counting frames normally (33081 total frames —with error messages). I verified that the messages were being received normally by the gateway like image[2]. I also checked that my device was active by otaa as shown in figure [3] and the frame counter had stopped with 32768. My frame counter is disabled too. Does anyone have any ideas about this error?

Fig.1
app

Fig.2

Fig.3

32768 seems like a strange number for uplink to break on. (at least for 1.0.x)
Perhaps something in the node stack you use?
Looks like something I have to try too. We have now nodes in the field with only uplink count of 21000.

The MIC (Message Integrity Code) is validated using the root key of the device. So either the join-request is corrupted or the key does not match.

I thought it could be the frame counter, but I was normally counting messages received in error. The use of a 16-bit counter only means that the device would need to rejoin every 65535 frames. I reset the chirpstack server and still kept getting wrong messages in the application[fig.1].

I reset the chirpstack server and kept getting an error. If you check [fig.2], in theory my device was activated, with keys working. When I reset the server, if there were any errors in the keys, wouldn’t I have to reset them?

if your device is OTAA just restart it and endnode will automatically rejoined to the chirpstack

My question is if the error was in the device or in the chirpstack? I solved the problem by resetting my device.

Hello Guys!!!
Today the same problem occurred !!! The frame counter of the last message before sending as invalid MIC error was 32767. The error is in the code of my device, where the variable that accumulates the frames is defined as int. I will change to unsigned long and do the test !!!