I am running v1.87 on an esp8266. I am able to subscribe to an MQTT broker running on my local network. I can publish and subscribe successfully.
I am attempting to publish from one esp8266 and subscribe from another. I believe that both boards use the same default client_id, because when I connect the second one, the first is disconnected.
I would expect to be able to work around this by setting a client_id in the MQTT connection options, as described here: http://www.espruino.com/MQTT
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 1 col 131
...nect({client_id:'webmos02'}),mqtt.on('connected',function(){...
^
in function called from system
I have tried putting in other things in the connection options, like _protocolname: "MQTT" and get the same result. I get errors regardless of what I put in as a connection option.
If I leave out the connection option I am able to connect and both publish and subscribe.
Am I correct in assuming that two different esp8266s without a client_id set will use the same client_id and thus collide?
How do I set a client_id?
Is there possible another way to resolve this issue?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I am running v1.87 on an esp8266. I am able to subscribe to an MQTT broker running on my local network. I can publish and subscribe successfully.
I am attempting to publish from one esp8266 and subscribe from another. I believe that both boards use the same default client_id, because when I connect the second one, the first is disconnected.
I would expect to be able to work around this by setting a client_id in the MQTT connection options, as described here: http://www.espruino.com/MQTT
My code looks like this:
I get these errors:
I have tried putting in other things in the connection options, like _protocolname: "MQTT" and get the same result. I get errors regardless of what I put in as a connection option.
If I leave out the connection option I am able to connect and both publish and subscribe.