MQTT subscribe not working? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
MQTT subscribe not working?
No permission to create posts
November 1, 2017
12:54 pm
Avatar
tchaloupka
New Member
Members
Forum Posts: 2
Member Since:
November 1, 2017
sp_UserOfflineSmall Offline

Hello,

I've tried to follow specification of the MQTT subscribe API to grab the feed from some public channel, but it doesn't seems to work (at least now): https://www.mathworks.com/help/thingspeak/subscribetoachannelfeed.html

Tried with the described MQTT.fx client and also with mosquitto_sub.

Here is the command line I tried for the public weather feed from the API docs:

mosquitto_sub -h mqtt.thingspeak.com -t channels/12397/subscribe/json -d -v -V mqttv311

 

Debug output is just:

Client mosqsub|20264-zld52_lin sending CONNECT
Client mosqsub|20264-zld52_lin received CONNACK
Client mosqsub|20264-zld52_lin sending SUBSCRIBE (Mid: 1, Topic: channels/12397/subscribe/json, QoS: 0)
Client mosqsub|20264-zld52_lin received SUBACK
Subscribed (mid: 1): 128
Client mosqsub|20264-zld52_lin sending PINGREQ
Client mosqsub|20264-zld52_lin received PINGRESP

...

 

It communicate as it should, but doesn't sending data.

Is the provided API actually working or am I doing something wrong?

November 1, 2017
2:08 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 287
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

I just tried to subscribe to the weather channel with MQTT.fx and it is working.  Your syntax for the topic looks correct. "channels/12397/subscribe/json" Can you describe what happened with the fx client?  Did you set your MQTT API key as the password?  There is a troubleshooting page that might help.  Ill try mosquitto_sub and see if I can get that to work.

November 2, 2017
3:20 am
Avatar
tchaloupka
New Member
Members
Forum Posts: 2
Member Since:
November 1, 2017
sp_UserOfflineSmall Offline

Thanks for the reply, the problem was the password as I thought that for public feed I don't need to use the MQTT API key as is mentioned in the documentation. But it is valid only for the topic itself not the user credentials.

 

When I tried:

mosquitto_sub -u username -P MQTT_API_key -h mqtt.thingspeak.com -t channels/12397/subscribe/json -d -v -V mqttv311

 

It started to work.

It also works with the MQTT.fx with correct user credentials.

 

Thanks.

November 2, 2017
3:01 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 287
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

 Thank you for posting your solution.  The documentation will be updated to help prevent that confusion.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: samdavies
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Lakshmanaprakash S B, bettetj60, ronnievw3, bessiesj18, Pavan kumar, Williampup

Administrators: Hans: 387, lee: 457