Mqtt + Http

39 views
Skip to first unread message

Shantanu Jagtap

unread,
Aug 26, 2016, 7:01:26 AM8/26/16
to MQTT
Hi,
I am trying to run a device as a mqtt client and also as a webserver. I am working with NodeMcu esp826612E. It supports arduino ide.

Now, I have been able to connect to the mqtt broker AND also run as a webserver.

My problem is, I need to start the webserver ONLY when Mqtt broker is absent. How do i do that? I am guessing PING is the best option.
If i receive a PING bak, mqtt broker is connected.
If no PING received, Start as a webserver and accept http requests.

How do I write this code for PING? There isnt much documentation on PING on the net. Please help.

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Aug 26, 2016, 12:01:16 PM8/26/16
to mq...@googlegroups.com
You could handle the connection lost event in a callback. http://www.eclipse.org/paho/files/mqttdoc/Cclient/pubasync.html 

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Shantanu Jagtap

unread,
Aug 27, 2016, 12:13:41 AM8/27/16
to MQTT
Hey. That looks good! Thank you. Also, lastly, will it be possible to parallelly perform two acitions?
1. Trying to reconnect with the mqtt broker.
2. Start esp8266 as webserver and accept http requests.

 Can both these actions be performed at the sam


On Friday, 26 August 2016 21:31:16 UTC+5:30, cogitoergosum wrote:
You could handle the connection lost event in a callback. http://www.eclipse.org/paho/files/mqttdoc/Cclient/pubasync.html 
On Fri, Aug 26, 2016 at 4:31 PM, Shantanu Jagtap <shantanu.j...@gmail.com> wrote:
Hi,
I am trying to run a device as a mqtt client and also as a webserver. I am working with NodeMcu esp826612E. It supports arduino ide.

Now, I have been able to connect to the mqtt broker AND also run as a webserver.

My problem is, I need to start the webserver ONLY when Mqtt broker is absent. How do i do that? I am guessing PING is the best option.
If i receive a PING bak, mqtt broker is connected.
If no PING received, Start as a webserver and accept http requests.

How do I write this code for PING? There isnt much documentation on PING on the net. Please help.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

unread,
Aug 27, 2016, 12:39:08 AM8/27/16
to mq...@googlegroups.com
Perhaps; I am not a C expert. :)

Regards,
Nagesh

To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages