Most recent activity
-
-
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.
I didn't met anybody here who used MQTT on js controller and not much people working with internet connection on js contoller. Usually it's just kids plays and thats it. I think, js controllers can do really great things and try to prove it.
I didn't tell about iskra just because don't think it could be important. So, please accept my I apologize. It certainly was not intentional. -
lI wonder whether you're connecting to an MQTT-SN server rather than normal MQTT, or something like that?
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.
And today I have a new problem with my yesterday-somehow-worked code. Espruino can't publish messages now.Uncaught Error: Field or method "length" does not already exist, and can't create it on Number at line 1 col 88 ...lish",c),b.emit("message",c.topic,c.message);else if(d!==f.P... ^ in function called from system at line 1 col 24 a=g(a);var c=b.length+e.length,d="";do{var f=c&127,c=c>>7;0<... ^ in function "m" called from line 1 col 95 ...?l(a):l(a)+d;return m(c,a,b) ^ in function "q" called from line 1 col 42 this.client.write(q(a,b,e||this.C.DEF_QOS)) ^ in function "publish" called from line 45 col 36 mqtt.publish('/iskra', humidity); ^
Could it be relevant to last updates? didn't look to changes so far.
-
Gordon and thank you for support! I really appreciate it.
Ok, about 'json-solution'. I've been testing it for few hours.
it's not working for the moment.
best results look like this:JSON TEST {"topic":"3865","message":"","dup":1,"qos":0,"retain":0}
topic was '/test', message contain a string, but not ':'
most part I've got undefined and thats it. But in debug i can see whole message and topic as it was sent.
As well I got one new error:Uncaught Error: Unknown Timeout at line 2 col 149 ...ACK)if(clearTimeout(b.ctimo),c=c.charCodeAt(3),0===c)b.conne...
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'.
It's the same when I send message either from espruino, websocket console or android client.
Maybe I can change type somehow? How it works? Need a research this.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.
-
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);
setting client_id didn't help, but i tried :)
By the way, I still have issue in the connect (a.write dose not already exist, if i'm not mistaken), but this solution let mqtt run, so for now i just ignore the issue. -
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
function mqttRun(){ var server = 'my_broker'; var options = { keep_alive: 60, port: my_port, clean_session: my_port, client_id: "my_id", username: "my_user", password: "my_pass", protocol_name: "MQTT", protocol_level: 4, }; var mqtt = require("MQTT").create(server, options); // changes here mqtt.on('connected', function() { mqtt.subscribe("/test"); }); mqtt.on('publish', function (pub) { // this place throw error console.log("topic: "+pub.topic); console.log("message: "+pub.message); }); mqtt.connect(); }
Uncaught Error: Field or method "topic" does not already exist, and can't create it on undefined
-
Thank you, Gordon.
do you mean put it in order like this?function mqttRun(){ var server = 'my_broker'; var options = { keep_alive: 60, port: my_port, clean_session: my_port, username: "my_user", password: "my_pass", protocol_name: "MQTT", protocol_level: 4, }; var mqtt = require("MQTT").create(server); mqtt.on('connected', function() { mqtt.subscribe("test"); }); mqtt.connect(options); }
I tried now - same error
>mqttRun() Client connected Uncaught Error: Function "write" not found!
What I'm doing wrong?
UPD. I saw this subject - http://forum.espruino.com/conversations/293870
example in post #5 and mine shoud do the same, but they don't -
Hello!
I'm trying to run mqtt client on my espruino. And have errors all the time. I tried to do it with options:function mqttRun(){ var server = 'my_broker'; var options = { keep_alive: 60, port: my_port, clean_session: my_port, username: "my_user", password: "my_pass", protocol_name: "MQTT", protocol_level: 4, }; var mqtt = require("MQTT").create(server); mqtt.connect(options); mqtt.on('connected', function() { mqtt.subscribe("test"); }); }
and as result got:
Client connected Uncaught Error: Function "write" not found! at line 1 col 35 ....log("Client connected");a.write(b.mqttConnect(b.client_id))... ^ in function "e" called from line 3 col 353 ..."close")});b.client=a};a?e():a=require("net").connect({host:... ^ in function "connect" called from line 27 col 23 mqtt.connect(options); ^ in function "mqttRun" called from line 1 col 9 mqttRun()
Without options I tried to connect with eclipse sandbox, and it works different:
mqttRun() ["AT+CIPSTART=0,\"TCP\",\"iot.eclipse.org\",1883\r\n" =undefined Client connected ] "\r\n" <--- "\r\n" ] "OK\r\n" <--- "OK\r\n" ] "\r\n" <--- "\r\n" ] "0, CO" <--- "0, CO" ] "0, CONNEC" <--- "NNEC" ] "0, CONNECT OK\r" <--- "T OK\r" ] "\n" <--- "\n" ] "\r" <--- "\r" ] "\n> " <--- "\n> " ] "\r\n" <--- "\r\n" ] "0, SE" <--- "0, SE" ] "0, SEND O" <--- "ND O" ] "0, SEND OK\r\n" <--- "K\r\n" ] "\r\n+RECEI" <--- "\r\n+RECEI" ["AT+CIPCLOSE=0,1\r\n" MQTT client disconnected MQTT client disconnected Uncaught Error: Unknown Interval at line 1 col 62 ...ted");clearInterval(b.pintr);b.emit("disconnected");b.emit("... ^ in function called from system ] "+RECEIVE,0,4:\r\n " <--- "VE,0,4:\r\n " ] "+D,0,3:\x02\x00\x00" <--- "\x02\x00\x00" ] "\r" <--- "\r" ] "\n> " <--- "\n> " ] "\r" <--- "\r" ] "\n0, " <--- "\n0, " ] "0, SEN" <--- "SEN" ] "0, SEND O" <--- "D O" ] "0, SEND OK\r\n" <--- "K\r\n" ] "\r" <--- "\r" ] "\n0, " <--- "\n0, " ] "0, CLO" <--- "CLO" ] "0, CLOSE" <--- "SE" ] "0, CLOSED\r\n" <--- "D\r\n"
Could I fix it somehow?
@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.
I didn't try MQTT module since friday's early morning. But when I do, let know what will get. I need to test Ollie suggestion as well.