Closed lorneb closed 7 years ago
i can't see anything obviously wrong with your code snippet. when you say "random amount of time" are we talking seconds, minutes, hours...? i presume you are still getting your "hello world" message every 2500ms?
have you tried playing with some of the definitions in https://github.com/mrdunk/esp8266_mdns/blob/master/mdns.h ?
in particular, this library carves off a huge chunk of memory in which to store incoming network data. (if i ever work on this code again i'll be reworking this section so the large buffer is not required.) it's possible you are running out of memory on the esp8266? try lowering MAX_PACKET_SIZE in mdns.h . also try enabling debugging in mdns.h .
i've just made a small change to address a potential buffer overflow when reading data from the network: https://github.com/mrdunk/esp8266_mdns/commit/ce84aa49ccacfa475746789a29211cc3a350c5a4#diff-807d3ef722282e3efc185703761877f2 this makes it safe to experiment with lower MAX_PACKET_SIZE values without risking a buffer overflow. test the return value of my_mdns.Check() to make sure data was successfully read from the network.
you can see how i started using this library here: https://github.com/mrdunk/home_automation_2/tree/master/esp8266/TestServer i can't actually remember if that code does anything useful in it's current state... it's been a year since i did anything with it also uses mDNS to connect to MQTT brokers.
No it doesn't do anything useful in it's currnet state, the code won't compile as it stands it's missing the definition for the MQTT type.
TestServerMrDunk:88: error: 'MQTT' does not name a type
void mqtt_callback(const MQTT::Publish& pub) {
^
TestServerMrDunk:88: error: expected unqualified-id before '&' token
void mqtt_callback(const MQTT::Publish& pub) {
^
Using the example mdns_test as a base, after I obtain IP address for MQTT service and connect using: PubSubClient @ http://pubsubclient.knolleary.net/
I have verified IP address for server is fine, connection is made, publish is sent, after a what seems a random amount of time mqtt disconnects, and will not reconnect.
same sketch with mDNS query commented out and IP address hard coded runs forever.