nickovs / slimDNS

Simple, Lightweight Implementation of Multicast DNS
Apache License 2.0
86 stars 9 forks source link

Advertising mDNS service #6

Open DavidM42 opened 5 years ago

DavidM42 commented 5 years ago

Is it possible to advertise the ESP-8266 as mDNS service with this library? There is nothing in the README but I saw the advertise_hostname method. Tried it but could not get my device to be scanned by avahi. Am I doing wrong or is it not supported? After connecting to the wifi I tried it with

from httpModules.slimDNS import SlimDNSServer, test
import network
sta_if = network.WLAN(network.STA_IF)
local_addr = sta_if.ifconfig()[0]
server = SlimDNSServer(local_addr, "espname")
response = server.advertise_hostname("servicename")

while (True):
    read_sockets = [server.sock]
    r = list(read_sockets)
    if server.sock in r:
        server.process_waiting_packets()

but I can't discover the ESP

cartufer commented 5 years ago

I may or may not be having the same issue, i am running on esp32, in a thread. I have debug print messages showing that it is getting the packets and is attempting a reply packet, but my windows 10 with bonjour is not able to ping it with mdns but is with just the ipv4.

nickovs commented 5 years ago

Sorry you are having trouble. This should work fine on both the ESP32 and the ESP8266 and I have both running fine on my network. Can you tell me what versions of Micropython you are running? The support for multicast in the network module has varied over the last year. Also, @cartufer, can you post the code you are using?

cartufer commented 5 years ago

My code is in https://github.com/cartufer/naiot the slimdns script i think is unmodified, apart from uncommenting some debug printouts. I use testThread() in main.py to launch slimdns. I am running "MicroPython v1.10 on 2019-01-25; ESP32 module with ESP32". Attached is a screenshot of both terminals. Let me know if i can help with testing, i am not advanced in python but i'm willing to run tests. slimdns_capture

cartufer commented 5 years ago

I'm not sure if its a socket problem, it may be but i'm starting to think its how packets are being handled. I reverted my esp32 to 1.9.4 and connected to my network. It is still behaving as before, i suspect certain computers/network environments don't take kindly to as you put it in slimDNS.py "We fake the handling of unicast replies.". I don't really have this kind of expertise though and if its working for you then it may be hard to debug on your end. I'm just going to have to find a workaround for referencing my devices.

stoefln commented 4 years ago

Does not work on my ESP8266 nodemcu board either :(