EDIT: The issue below was caused by me. I leave this as a cautionary tale to check your own network before troubleshooting external dependencies
Hello!
I have an issue with connecting to the TTN MQTT broker to retrieve uplink messages. I have followed the intstructions on the Quick Start page, using the application id as the user name, and the access key as the password, as pasted using the ācopy to clipboardā button in the console UI.
I am trying to subscribe to the topic testpi1/devices/pie-one/up, where testpi1is my application id, and pie-one is my device id. The full command line is as follows:
Hi @cultsdotelecomatgmai, and thanks for replying.
Iāve used quotes surrounding the topic argument before with other brokers, and it has worked fine. I have ommitted it for this second try, however. I also removed the quotes from the user name and password arguments, but it didnāt make any observable difference.
Client mosq-nrhcio59Vb0jTkz7Dr sending CONNECT
Client mosq-nrhcio59Vb0jTkz7Dr received CONNACK (5)
Connection error: Connection Refused: not authorised.
Client mosq-nrhcio59Vb0jTkz7Dr sending DISCONNECT
It is almost as if there is something wrong with how I have set up my application. I do get application data if I look in the console, and the payload looks like what I would expect.
Hi again @Zorander, this is probably a stupid question but can you confirm that testpi1 is the name of the application on the TTN core and that the key you are using does have access to the application and the privilege to see data.
The name of the application is indeed ātestpi1ā, and the key is verbatim as is shown on the page for that application, starting with ttn-account-v2.. It has the permissions devices and mesages.
This is the first time Iām trying to use any of the TTN brokers. Iāve been able to connect with my own brokers that I use for other projects outside of TTN, as well as the test broker at test.mosquitto.org.
Something is up. I double checked the behaviour with test.mosquitto.org, and for some reason Iām unable to connect to any broker using Mosquitto from any of my machines. Iāll have a look to see if thereās something awry with my ISP.
Feel free to try; Iāll remove the above key, switch off the test node and edit this post later tonight. (Yes, itās a different application ID than shown in the screenshot I posted.)
This temporary key only has access to messages. You can easily add additional keys; maybe that helps, somehow?
Thanks for taking the time to help me. I appreciate it very much.
I found out the problem. By connecting to one of my VPS machines, I was able to access the messages for both your application as well as mine. test.mosquitto.org works fine as well.
The issue was an incorrect Source NAT rule on my firewall. It was simply connecting back to the Mosquitto server that Iām hosting on my internal Kubernetes cluster, and the credentials were of course rejected.
Iāll leave this as a cautionary tale to double check your local network before investigating external services.
Thanks again for your help, all of you. Have a nice evening!
Ooops, my last message even had a lowercase -p, rather than the uppercase -P that I actually used after getting an error message about an invalid port number.
Also, fun fact: removing a key does not invalidate existing MQTT sessions. That is: not immediately; it took about 22 minutes (about 131 messages) in my quick test for the connection to suddenly fail.