hazelcast-csharp-client: Application throw when attemting gracefull shutdown if client never connected [API-2054]

Hello,

As of today there’s no way to pass a CancellationToken when calling var client = HazelcastClient.NewHazelcastClient(config); Could you add it to the Api when creating an HazelcastClient ? var client = HazelcastClient.NewHazelcastClient(config, myOwnCancellationToken); That way i could properly pass on the existing StoppingToken from AspNetCore, or my own if i have to decide of the lifetime the big issue here is that Hazelcast is mainly Blocking/Sync Api without proper counter measure for the consumer on edge case

Repro

if you create an aspnetcore app : dotnet new webapi

(pseudo code)

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddHostedService<HzClientService>();
    }
}

/////
public class HzClientService : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        await Task.Yield();

            var clientConfiguration = new ClientConfig();
            clientConfiguration.GetNetworkConfig().AddAddress(new [] { "localhost:5701", "localhost:5702"});

            clientConfiguration.GetNetworkConfig().SetRedoOperation(true);
            clientConfiguration.GetNetworkConfig().SetConnectionAttemptLimit(50);

        var client = HazelcastClient.NewHazelcastClient(clientConfiguration);
    }
}
  • DO NOT START THE CLUSTER,
  • Configure the IDE to run in the Console and not IIS Express and press F5
  • Wait for the console to show, and wait like 5 sec (so that it should to few retry
  • Press Ctrl+C in the console to trigger a Gracefull shutdown

It will not be gracefull one and will throw 😦 image

image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (1 by maintainers)

Most upvoted comments

I think we can reasonably consider this a defect. While it will be fixed in the long run with v4, we could investigate whether there is indeed a “quick fix” for it in the v3 branch. @burakcelebi ?