chkr1011 / CoAPnet

CoAPnet is a high performance .NET library for CoAP based communication. It provides a CoAP client and a CoAP server. It also has DTLS support out of the box.
MIT License
70 stars 15 forks source link

New version of libraries not connecting to Tradfri #10

Closed gkapellmann closed 2 years ago

gkapellmann commented 2 years ago

So, I got this code to connect to an IKEA Tradri:

`public static async Task ConnectTradfri(ICoapClient theClient, string IP, string ID, string secretKey) { Console.WriteLine("< CONNECTING...");

        var connectOptions = new CoapClientConnectOptionsBuilder()
            .WithHost(IP)
            .WithPort(5684)
            .WithDtlsTransportLayer(o => o.WithPreSharedKey(ID, secretKey))
            .Build();

        using (var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(taskTimout))) {
            await theClient.ConnectAsync(connectOptions, cancellationTokenSource.Token);
        }

    }`

That works perfectly well when using the libs from version [1.0.9], but now that I upgraded to version [1.1.0] the same code is unable to connect. It now needs .ConfigureAwait(false); at the end.

Has something changed that I am missing? Or why could this be happening?

chkr1011 commented 2 years ago

Is "ConfigureAwait(false)" really the only change to get it working? What happens when there code is missing? Does it block forever or is there an exception?

chkr1011 commented 2 years ago

I assume this is fixed.