richardschneider / net-mdns

Simple multicast DNS
MIT License
227 stars 79 forks source link

Not getting any response for ResolveAsync #108

Open Raj123456788 opened 3 years ago

Raj123456788 commented 3 years ago
   I followed the documentation (https://github.com/richardschneider/net-mdns#async-queries) and added below code but if the device does not exists I am not getting any response? am I missing something?          

           var Nameservice = _hostname + "._airplay._tcp.local";        
            var query = new Makaretu.Dns.Message();
            var cancellation = new CancellationTokenSource(2000);
            query.Questions.Add(new Question { Name = Nameservice, Type = DnsType.ANY });
            var response = await mdns.ResolveAsync(query, cancellation.Token);
            if (response != null)
            {
                Debug.WriteLine($"Response received {response}");
            }
queequac commented 3 years ago

Hi @Raj123456788 , unfortunately I am not really a good help here, since I have no airplay devices and cannot test your query against them. But since you asked first in my unicast-related issue - does that mean you are assuming airplay depends on unicast? Most likely not...

Nevertheless, why are you adding the hostname in front of the _airplay._tcp.local? I guess your hostname does simply not match the actual name of the airplay device. You should try without that one and the dot, so any airplay device on the local network can respond. Then you can have a look through the results whether the one you are looking for is part of the result set.

Raj123456788 commented 3 years ago

@queequac Thanks for the reply. No I am not assuming airplay to be unicast :) I am adding _airplay._tcp.local because that is how that particular airplay device is advertised. I have already tried without .airplay still the same. I am hitting pause on this due to priorities but will post an answer if I find one. Thanks for the help!

queequac commented 3 years ago

I was not wondering that you add _airplay._tcp.local, more wondering that you put a well-known hostname in front. 😉

Raj123456788 commented 3 years ago

ohh, that was because I wanted response from that specific hostname if it already exists on the n/w. But the real problem is when it does not exists on the n/w despite of CancellationTokenSource set to 2 secs it never returned anything.

queequac commented 3 years ago

Is that not expected behavior, that nothing is returned if it does not exist? Or did I get you wrong?

Raj123456788 commented 3 years ago

That was my question to the author. Assuming it is correct behavior: If the hostname becomes active on the network after few mins of the query sent I still receive a response. Doesn't the query has a time out of just 2 secs? So I should never receive a response and Timeout is not working. I have fixed this problem by running a timer for 2secs and ignore the responses after 2 secs but I was wondering if Library handled that.

twofingerrightclick commented 2 years ago

Are you on Windows and using Wifi? There are several open issues citing that the library isn't working with Wifi interfaces, and I am not sure if this just limited to Windows devices, but that is the only devices I have tried it with. Try plugging in via Ethernet and turn off Wifi on your machine. I and several others have observed that we are only able to use the library with ethernet interfaces at the moment. I haven't yet delved into as to why.