Skip to content

Server stops responding after 65536 requests in simple test app #95

@Jepplar

Description

@Jepplar

I'm running into an issue where the CoAP server seemingly stops responding to the client after 2**16 requests in one of my applications.
I have separated the issue into a simple test server+client as outlined below which replicates the issue.

Even though the client sends 100k requests, only 65k of them are received by the server.
Adding a sleep when sending requests, waiting for ACK etc does not seem to make a difference.

Any ideas on how to resolve the issue?

Server code:

namespace CoapTestServer
{
    internal class Program
    {
        static void Main(string[] args)
        {
            CoapServer server = new CoapServer();

            server.Add(new TestResource());
            server.Start();

            Console.WriteLine("Running...");
            Console.ReadKey();
        }
    }

    class TestResource : Resource
    {
        static long connectionCount = 0;

        public TestResource() : base("test-resource")
        {
        }

        protected override void DoGet(CoapExchange exchange)
        {
            long newCount = Interlocked.Increment(ref connectionCount);
            Console.WriteLine($"Server received {newCount} requests");

            exchange.Respond("This is a response");
        }
    }
}

Client code:

Uri hostUri = new Uri("coap://localhost/test-resource");
for (int i = 0; i < 100 * 1000; i++)
{
    try
    {
        Request request = new(Method.GET, false)
        {
            URI = hostUri,
        };

        request.Send();
        request.WaitForResponse();

        Console.WriteLine($"Client sent {i} requests");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"{ex.Message}");
    }
}

Console.WriteLine("Finished, press enter to exit");
Console.ReadLine();

Output:
image

I am using NuGet package 1.10.0 of "Com.AugustCellars.CoAP" with .NET 7.0 and Visual Studio 2022 on Windows 10.

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