Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responses to unicast queries not received #91

Open
queequac opened this issue Jan 1, 2020 · 11 comments
Open

Responses to unicast queries not received #91

queequac opened this issue Jan 1, 2020 · 11 comments

Comments

@queequac
Copy link

queequac commented Jan 1, 2020

Hi, I am currently playing arround with the library to check whether I can use it in production.
Doing so I realized that I do not receive responses for SendUnicastQuery.

var mdns = new MulticastService();
mdns.UseIpv6 = false;
mdns.NetworkInterfaceDiscovered += (s, arg) =>
{
    var query = new Message();
    var question = new Question() { Name = "_googlecast._tcp.local.", Type = DnsType.PTR, Class = DnsClass.ANY };
    query.Questions.Add(question);
    //mdns.SendUnicastQuery("_googlecast._tcp.local.", DnsClass.ANY, DnsType.PTR); // Even though response is on "wire", it never triggers AnswerReceived
    mdns.SendQuery(query); // Works, all responses arrive at the multicast address
};
mdns.AnswerReceived += (s, arg) =>
{
    Debug.WriteLine(arg.Message.ToString());
};
mdns.Start();

I am using Wireshark and I can see queries being sent and also getting responses in both cases on the wire.

Using above code, SendQuery will result in AnswerReceived events (arriving at the multicast address 224.0.0.251), while uncommented SendUnicastQuery will not (even though I can see a response being sent from the device directly to my IP address).

I tried with UWP as well as .NET Framework 4.7.

And idea?

Best, Roland

@queequac
Copy link
Author

queequac commented Jan 2, 2020

With the additional line in the PR it works and I can successfully receive answers for those unicast queries on my local endpoint.

Since receivers are a superset of senders in this case, it might be sufficent to dispose that list only.

@queequac
Copy link
Author

queequac commented Jan 2, 2020

Slightly off-topic, but I am nosy.

What is the following line good for?

static readonly IPNetwork[] LinkLocalNetworks = new[] { IPNetwork.Parse("169.254.0.0/16"), IPNetwork.Parse("fe80::/10") };

I have looked through your dependencies, and this line is the only reason for the IPNetwork2 package.
Interestingly enough, there is not a single reference to LinkLocalNetworks in the entire solution.

@Raj123456788
Copy link

Hello, can you provide a working example for sending query?
mdns.NetworkInterfaceDiscovered += (s, arg) =>
{
var query = new Message();
var question = new Question() { Name = "_googlecast._tcp.local.", Type = DnsType.PTR, Class = DnsClass.ANY };
query.Questions.Add(question);
//mdns.SendUnicastQuery("_googlecast._tcp.local.", DnsClass.ANY, DnsType.PTR); // Even though response is on "wire", it never triggers AnswerReceived
mdns.SendQuery(query); // Works, all responses arrive at the multicast address
};

@queequac
Copy link
Author

@Raj123456788 Sorry, I do not understand your request. The code shown in my first comment and which you partly copied is already a working sample for multicast. For unicast you have to comment out the last line and re-enable the line above (SendUnicastQuery). But this does only receive messages when taking over PR #92

@Raj123456788
Copy link

@queequac : thanks. Will try that. I have another question: I need to get a list of all services published on a n/w before I start my service(want to avoid publishing a service that is already published).
Problem: I receive the answer to query pretty late by the time I have already sent my publish request. I was trying to find a full proof way to do this. Let me know if you have any suggestions!

@queequac
Copy link
Author

Hi @Raj123456788 , could you please stop spamming this thread, since your questions are totally unrelated to the issue? I don't want @richardschneider to close it just because of noise here.

btw, you will find answer to all your questions on the starting page anyway. Your last questions seems to be solvable via ResolveAsync and a cancelation token expiring in maybe 2seconds.

@Raj123456788
Copy link

@queequac : My apologies. I will create another issue henceforth. Thanks for the answer.

@Raj123456788
Copy link

@queequac: Did you ever get an answer for unicast queries response?

@queequac
Copy link
Author

queequac commented Aug 4, 2021

@Raj123456788 Sure, see my PR above... the code changes make it work with unicast queries.
I simply closed the corresponding pull request, since this repo is obviously no longer maintained and noone cares for the PR anyway.

@Raj123456788
Copy link

Hi @queequac : If you have any idea can you please answer my question #108
Thanks!

@Jeekate
Copy link

Jeekate commented Feb 19, 2022

I met the same issue contacting to my esp8266, thanks for your PR!!

jdomnitz added a commit to jdomnitz/net-mdns that referenced this issue May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants