MQTT subscription failure

Hi,

I'm working on the Thingy91 'asset tracker v2' project. I see the data on the nRF cloud. Now, I want to subscribe for incoming data over my Android or Windows app. The connection breaks when I try to subscribe to the MQTT endpoint.

The thing I did is as follows:

  • Flashed the Asset Tracker V2 firmware on Thingy91
  • Got the certificate and clientId from 'POST api.nrfcloud.com/.../certificates'
  • Converted the received JSON to separate files using the nRF LTE Link Monitor app
  • Subscribing with mosquito using a command like this:

mosquitto_sub.exe -h ${mqttEndPoint} -t ${deviceId}/shadow/get/accepted --cert ./ssl\client.crt --cafile ./ssl\ca.crt -p 8883 --key ./ssl\client.key -d -i ${clientId}

Where the ${mqttEndPoint}, ${deviceId} and, ${clientId} is replaced with the real values obtained from nRF cloud.

When I subscribe to the topic mentioned above, everything seems fine, and the result is like this (the clientId and other information is replaced with ****):

Client nrf-*************** sending CONNECT
Client nrf-*************** received CONNACK (0)
Client nrf-*************** sending SUBSCRIBE (Mid: 1, Topic: nrf-***************/shadow/get/accepted, QoS: 0, Options: 0x00)
Client nrf-*************** received SUBACK
Subscribed (mid: 1): 0

But the moment something is published on that topic from Thingy91, it breaks the connection:

Client nrf-*************** sending CONNECT
Client nrf-*************** received CONNACK (0)
Client nrf-*************** sending SUBSCRIBE (Mid: 1, Topic: nrf-***************/shadow/get/accepted, QoS: 0, Options: 0x00)
Client nrf-*************** received SUBACK
Subscribed (mid: 1): 0
Error: The connection was lost.

However if I subscribe to the 'prod/${tenantId}/m/#' topic or any other topic starting with m, the connection breaks right away; the output is as follows:

Client nrf-*************** sending CONNECT
Client nrf-*************** received CONNACK (0)
Client nrf-*************** sending SUBSCRIBE (Mid: 1, Topic: prod/***********/m/#, QoS: 0, Options: 0x00)
Error: The connection was lost.

As described here, I should be able to subscribe to this topic.

One more thing, after I try to connect via mosquitto or MQTT Explorer, the Thingy91 gets disconnected, and I can not connect again. I have to remove the device from the nRF cloud and add it again!

Any idea what is wrong?

Parents Reply
  • That is the case. I use the same clientId and credentials that are received by calling the 'POST on api.nrfcloud.com/.../certificates'. If I use a different clientId (added '-2' at the end), it does not connect (connection breaks before the connection is complete):

    Client nrf-**************-2 sending CONNECT
    Error: The connection was lost.

    When the Thingy91 is disconnected, the same thing happens, and the connection breaks (even when using the same clientId as Thingy91).

    Where can I get the new clientId for new connections? Do I need a different certificate to be able to connect to the MQTT broker?

Children
Related