Skip to content

Discover not Multicast Ready #66

Open

Description

@Alv3s

I have been playing with this library to discover CoAP devices using my own library on the microcontroller (ESP8266): https://github.com/Alv3s/Thing.CoAP

It seems CoAP.NET is not ready for this feature. Microcontroller is configured to respond to CoAP multicast address (224.0.1.187), I am opening a client to this coap endpoint "coap://224.0.1.187/" and I was expecting to discover all the resources of all available CoAP devices on the network. But it seems I am only getting the first one.

I tried to do as follows:

CoapClient client = new CoapClient(new Uri("coap://224.0.1.187/"));
            client.Respond += Request_Respond;
            var result = client.Discover().ToList();

            for (; ; )
            {
                Thread.Sleep(1000);
            }

The code above only returns the first device replying to the request. I also tried as follows:

        static void CoAPMulticast()
        {
            // new a GET request
            Request request = new Request(Method.GET, false);
            request.Multicast = true;
            request.URI = new Uri("coap://224.0.1.187/.well-known/core");
            request.Respond += Request_Respond;

            request.Send();

            for (; ; )
            {
                Thread.Sleep(1000);
            }
        }

private static void Request_Respond(object sender, ResponseEventArgs e)
        {
            Console.WriteLine("Here");
        }

I was expecting function "Request_Respond" to print twice the "Here", but I can see on the logs that the second response is being ignored.

Any tips? Maybe I could help you with this one.

Activity

  1. mfalkvidd commented on Feb 13, 2020

    @mfalkvidd

    Does the request reach all the clients? Should be easy to verify by checking the logs for multiple devices.

    Do all the clients' responses reach the computer where the client is running? Easiest way to verify is probably to run wireshark on the computer.

  2. Alv3s commented on Feb 13, 2020

    @Alv3s
    Author

    @mfalkvidd Thank your for the reply. I did verify and checked the multicast request reached both devices and both devices response reach CoAP.NET. I could verify this with Wireshark and also via logs generated on the console by CoAP.NET.

    The issue seems to be the Discover method is only expecting one response (which usually it is fine). I guess a method called "DiscoverAll" could be created and return an IEnumerable of Devices with weblinks. If that seems fine to you, I could implement it and open a merge request for you.

  3. mfalkvidd commented on Feb 13, 2020

    @mfalkvidd

    I don't have control over this repository, and I don't use multicast myself, but your suggestion sounds good.

    I'm not sure anyone is maintaining this repo anymore. I submitted a pull request quite a while ago: #64

    I would prefer that this repo remained the "true" source for the project, but you are welcome to submit a pull request to my fork if you have no luck here.

    There are a few other forks as well: https://github.com/smeshlink/CoAP.NET/network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions