MQTT not working? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
MQTT not working?
Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
1
September 30, 2017 - 10:35 am
sp_Permalink sp_Print

Hello,

i have a device that has been posting data for a long time. It’s based on ESP8266 and uses pub sub as mqtt library. 

About a day ago data disappeared from the dashboard. I am traveling so I don’t have physical access but I see that it is working nicely as it also syslogs locally. I reset it from remote but no help. Sys log says it can’t connect to mqtt. 

Firmware has not changed, connectivity is in place and tested. Has anything changed on the thingspeak side?

anyone having similar issues?

thanks!

Avatar
Vinod

Forum Posts: 152
sp_UserOfflineSmall Offline
2
October 2, 2017 - 9:58 am
sp_Permalink sp_Print sp_EditHistory

There are no reported issues with the MQTT publish functionality at this time. The team confirmed this by testing from multiple networks.

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
3
October 4, 2017 - 9:53 am
sp_Permalink sp_Print sp_EditHistory

Vinod said
There are no reported issues with the MQTT publish functionality at this time. The team confirmed this by testing from multiple networks.  

Hello Vinod, 

I also tested with IoT devices and it can be reproduce easily just by using the bare-bones demo sketch of the ubiquitous PubSub library: https://github.com/knolleary/pubsubclient/blob/master/examples/mqtt_esp8266/mqtt_esp8266.ino

Most of the times it returns code MQTT_CONNECT_UNAUTHORIZED  5 and sometimes MQTT_CONNECTION_TIMEOUT   -4

My device has been running for months on the same firmware but it suddenly stopped on Friday September 29 at 1:49PM (GMT+2).

Please note that I was traveling in another continent so for sure nobody changed anything on my side...

May I ask you to submit this info to the team?

Thanks for your time!

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
4
October 4, 2017 - 10:19 am
sp_Permalink sp_Print

Vinod said
There are no reported issues with the MQTT publish functionality at this time. The team confirmed this by testing from multiple networks.  

Vinod, it does not even work anymore with your own example!

https://nl.mathworks.com/help/thingspeak/use-arduino-client-to-publish-to-a-channel.html

Avatar
JasonW

Forum Posts: 18
sp_UserOfflineSmall Offline
5
October 4, 2017 - 12:16 pm
sp_Permalink sp_Print

I just tried the example you linked to and I was able to get it to work.

However, I did need to change the client ID in the code to something unique.

Line 73, changed from:
   if (mqttClient.connect("ArduinoWiFi101Client"))
to
   if (mqttClient.connect("MyClient12345"))

There can be only one client at a time connected to the MQTT broker with a particular client ID.  So in my case someone was already connected with "ArduinoWiFi101Client".   

If you are using a generic client ID in your code, it is possible that another user is has decided to use the same client ID and is interfering with your device's ability to connect.

It looks like the ESP8266 code you referenced does take this into account by appending a timestamp to the client ID.  That would help ensure that your ID is unique.

We're going to update the examples in the documentation so that others don't get hit with this issue.

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
6
October 4, 2017 - 1:39 pm
sp_Permalink
Awaiting Moderation

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
7
October 4, 2017 - 2:43 pm
sp_Permalink sp_Print

Server bug confirmed

Even changing the ID, after a few iteration it starts failing.

The only way to have it somewhat working is to generate every time a random ClientID. Not sure if this is the way it is designed...

In any case it often fails with -4 (MQTT_CONNECTION_TIMEOUT).

Any chance you guys could take a look at it?

THANKS A MILLION

Avatar
mutton
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
8
October 5, 2017 - 6:41 am
sp_Permalink sp_Print

I've just had two channels stop reporting via MQTT as well.

They have been both reporting for months without a problem and both suddenly can't connect to the broker

 

regards

mutton

Avatar
JasonW

Forum Posts: 18
sp_UserOfflineSmall Offline
9
October 5, 2017 - 10:15 am
sp_Permalink sp_Print

Something else to try is adding a username and password to the connection request.  The additional parameters help the broker differentiate clients with the same the client ID.

For Publish operations the choice of a username and password are not important, you can use anything.  In the code it would looks like this:

 if(mqttClient.connect("MyVeryUniqueClientID_6F1EBB","SomeUsername","SomePassword"))

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
10
October 5, 2017 - 2:51 pm
sp_Permalink sp_Print

JasonW said
Something else to try is adding a username and password to the connection request.  The additional parameters help the broker differentiate clients with the same the client ID.

JasonW, the broker gets often confused even when the clientID is very unique...!

Any chance this new behaviour could be reported to the dev team?

thanks!

Avatar
JasonW

Forum Posts: 18
sp_UserOfflineSmall Offline
11
October 5, 2017 - 4:19 pm
sp_Permalink sp_Print

MarcFinns,

We have many many other MQTT clients that are publishing data without issue. There were no changes to our server near the Sept 29th.  So I'm trying to understand what is different in your case.

Did you try adding the username and password?  I am on the dev team. I'm asking you to try that for a specific reason as the result will help steer the troubleshooting effort.

Also if you can send me the client ID (or partial client ID) you are using, I can look through the server logs for additional details.

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
12
October 5, 2017 - 4:33 pm
sp_Permalink sp_Print

JasonW said
MarcFinns,

We have many many other MQTT clients that are publishing data without issue. There were no changes to our server near the Sept 29th.  So I'm trying to understand what is different in your case.

Did you try adding the username and password?  I am on the dev team. I'm asking you to try that for a specific reason as the result will help steer the troubleshooting effort.

Also if you can send me the client ID (or partial client ID) you are using, I can look through the server logs for additional details.  

Jason, I will recompile and give it a try. However believe me, this thing had been running for months... when this change of behaviour took place i was one continent away

Avatar
MarcFinns

Silver
Forum Posts: 10
sp_UserOfflineSmall Offline
13
October 15, 2017 - 5:16 am
sp_Permalink sp_Print

mutton said
I've just had two channels stop reporting via MQTT as well.

They have been both reporting for months without a problem and both suddenly can't connect to the broker

Hi Mutton, did you manage to achieve different results..?

This thing is sooooo broken and the company does not care obviously. Their site has not changed forever, clearly not a priority for them.

Avatar
Vinod

Forum Posts: 152
sp_UserOfflineSmall Offline
14
October 15, 2017 - 8:43 pm
sp_Permalink sp_Print sp_EditHistory

Marc - have you been able to reproduce the issue you see with a desktop client such as MQTTFx? We have tried numerous things and are unable to reproduce what you are seeing on your end.

We care deeply about ThingSpeak users and continue to add new features almost every month. Just last week we released MQTT subscribe, in addition to to the existing MQTT publish functionality. See here for the new subscribe API, in addition to the existing publish API. 

I have also asked for the lead developer, Jason, to reach out to you directly to try and reproduce the issue you are seeing since we are unable to reproduce this on our end.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 250

Vinod: 152

piajola: 74

vespapierre: 63

cstapels: 60

Adarsh_Murthy: 59

Newest Members:

bharad

mikebradley

gilloliver

chputney

fibula

namansahore

Forum Stats:

Groups: 4

Forums: 17

Topics: 1261

Posts: 4400

 

Member Stats:

Guest Posters: 1

Members: 5588

Moderators: 0

Admins: 2

Administrators: Hans, lee