MQTT newbie troubles #728
Replies: 30 comments
-
Posted at 2017-01-17 by @gfwilliams You could try registering for the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-17 by Ickis Thank you, Gordon.
I tried now - same error
What I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-17 by Ickis ok. this problem solved by setting options when 'create' but i have next one. i can see messages in debug, but mqtt module give me error again
Uncaught Error: Field or method "topic" does not already exist, and can't create it on undefined |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-18 by @gfwilliams Ok, glad you got that sorted - do you know what exactly the issue was? Missing For your new error, could you just try removing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-18 by @gfwilliams Actually can you try this instead:
It looks like 'publish' can return undefined if it doesn't understand the MQTT packet that it was sent, which would produce your error |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-18 by Ickis Gordon, thank you, i'll definitely try with json. I already looked through module code and and notice, when it can be undefined, so run my code without pub.topic and pub.message. mqtt.on('publish', ...) can catch the event, thats good. But still need to read messages for my project and still look for solution. Will try use JSON.stringify(pub) today and tell about result. And about first problem: it was solved when i set my options object as a parameter of 'create' function like this: mqtt.create (server, options); |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-18 by @gfwilliams Thanks for letting me know - it looks like the last updated to the documentation wasn't tested at all. Looking through it I've spotted loads of bugs in the example code now :( I'll push an update soon. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-18 by Ickis Gordon and thank you for support! I really appreciate it. Ok, about 'json-solution'. I've been testing it for few hours.
topic was '/test', message contain a string, but not ':'
it's not crash the script, but still. About MQTT packet: all the time i having 'MQTT unsupported packet type: 6' and 'MQTT unsupported packet type: 7'. and as soon as i can see topic and message in debug, probably i can get it to some buffer as well? I tried AT module, but not succeed with it so far. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-19 by @gfwilliams For the unsupported packet type, see http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Table_2.1_- Looks a lot like 6 and 7 are for To be honest QoS>0 isn't really so important over TCP/IP since TCP/IP will already be doing error correction and packet management for you. I wonder whether you're connecting to an MQTT-SN server rather than normal MQTT, or something like that? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-19 by Ickis
I'm not sure that understand you right way, do you ask which broker I use? If so, I try cloudmqtt.com and iot.eclipse.org - same result.
Could it be relevant to last updates? didn't look to changes so far. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-20 by @gfwilliams I just tested here on an Espruino Wifi board with your code - publish and subscribe seem to work ok for me. Seems like your issue is that I just saw If so, you should really be asking Amperka for help - or at least letting us know that you're not using an Espruino board. Amperka are using Espruino for free - I can't afford to spend hours of my time supporting their customers as well! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-20 by Ickis Oh. I'm really sorry for bothering you. I didn't know that it is working this way, thought that it's just a forum where people could ask questions. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-20 by Ollie @Ickis There is this module also: https://github.com/olliephillips/tinyMQTT. You may experience the same issues, but worth a shot. Note the API is slightly different but it's on the README |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-20 by Ickis Ollie, thank you, didn't see that one. Will definitely try it and share the result. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-23 by @gfwilliams No problem, it's fine. I'm in a difficult situation - I want the forum to be to help other people out, but because I put a lot of time (~3 hours a day) into trying to help everyone on the forum and email, it makes life difficult if I end up spending that time helping out another company's customers! @Ickis I believe if you try again, after i posted the last comment I think I fixed the issues you were having with the MQTT module? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-23 by Ickis @gordon Sure, I can understand it. Actually, I was really surprised, when get answer from developer of module and such attention for my problem. It's of course takes time from you and your help is really appreciated. Sorry again for this misunderstanding. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-04 by Stephen- Just as a follow up I am testing with a pico wifi, eMQ as the broker, I see random errors with this code on the device:
It seems to randomly add \xD0\x00 to the message. Console.log
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-04 by Stephen- Update. testing with QoS mqtt.publish("test/espruino", msg, 1);
eMQ Console subscribed test/# QoS 1
mqtt.publish("test/espruino", msg, 2);
Nothing in eMQ Console subscribed to test/# |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-05 by @gfwilliams There isn't QoS support in the MQTT client so that would be your problem in the latter tests. Because MQTT is running over a TCP/IP link which has QoS itself, there is no need to have it. I've just made some changes to the MQTT library that will hopefully fix the problems you're having, so could you re-upload with the initial code and see if it is better? Do you know what data you were sending initially? At least one of the problems seemed to stem from |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-05 by Stephen- Hi Gordon, It seems that the clinet.on('data') is sending more than one message in the data item. Here is a fix I have hacked for MQTT.js, couldn't find it on github for a pull request.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-06 by Stephen- I have added some QoS handshake and some basic caching, need to get a replay after reconnect and drop old undelivered. See github https://github.com/srhart/MQTT |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-21 by CriscoCrusader I'm publishing the same topic over and over again, using the node mqtt module on my computer, and occasionally I'm getting incomplete data printed out in Espruino. I assume the Espruino MQTT code is to blame because the client matched on the topic, yet the output doesn't match.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-22 by Stephen- I had the same issue, it seems that the default MQTT module sometimes gets a ping reply and the message in a single packet and is not separating the two. Did you try the updated library I posted on Github? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-28 by CriscoCrusader @user75453, I did. I didn't have success. Are you sure you pasted valid JS? I recall a closing brace was missing, and some other issues which lead me to give up on that approach. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-28 by CriscoCrusader @user75453, for example, you have
but onConnect is not referrenced anywhere else. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-30 by Stephen- @CriscoCrusader, that is strange as I tested it with a Pico-WiFi and Mosquitto. What board are you using and how are you connecting to the broker? I had a local http server to serve my MQTT.js |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-05-30 by CriscoCrusader @user75453, my mistake, I haven't tried your github code. I tried the code snippet you show in reply #21. I hope the fix makes it into the official Espruino MQTT module. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-27 by pb-praha Hi Stephen For the record, I was running into the same issue of split data packets. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-06-27 by @gfwilliams I've just pulled this into the main repository (thanks @Stephen-!). Hopefully it'll go live in a day or two. Sorry it's taken so long to sort this one out. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-07-04 by Stephen- No problem, and thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-01-17 by Ickis
Hello!
I'm trying to run mqtt client on my espruino. And have errors all the time. I tried to do it with options:
and as result got:
Without options I tried to connect with eclipse sandbox, and it works different:
Could I fix it somehow?
Beta Was this translation helpful? Give feedback.
All reactions