Skip to content

Discover not Multicast Ready #66

@Alv3s

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.

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