0

I have made a simple Hazelcast topic publisher in C#.

My code is working on Linux, but not on Windows. Can you help me to understand why?

The code only executes to the line "code stops executing here".

public static async Task SubscribePublishToTopic(String topicSubscribe, String message)
{
    await using var client = await HazelcastClientFactory.StartNewClientAsync();
        
    Console.WriteLine("client added");

    await using var topic = await client.GetTopicAsync<String>(topicSubscribe);
        
    await topic.PublishAsync(message);
}

public static async Task Main(string[] args)
{   
    Console.WriteLine("We are here");
    await SubscribePublishToTopic("Test-Topic", "Hello World");
    Console.WriteLine("Subscriber added to Test-Topic");    
}
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
  • `The code only executes to the line "code stops executing here"` where is this `code stops executing` line? Please provide clear details and a minimal reproducible example so we can further help you. – Trevor Apr 28 '22 at 12:51
  • i do not see any "code stops executing here"-line... – Franz Gleichmann Apr 28 '22 at 12:51
  • My bad, it is the we are here line :) – Michael Chrestiansen Apr 28 '22 at 12:52
  • 1
    Try removing `Task` from `Main`, just a guess at first glimpse. – Trevor Apr 28 '22 at 12:53
  • Thank you for your suggestion. I tried to remove it like this: ``` public static void Main(string[] args) { Console.WriteLine("We are here"); SubscribePublishToTopic("Test-Topic", "Hello World"); Console.WriteLine("Subscriber added to Test-Topic"); } } ``` Is that what you meant? But it didn't solve the problem. I can reach the "Subscriber added to Test-Topic" line now, but still not the "client added" one – Michael Chrestiansen Apr 28 '22 at 13:07
  • @MichaelChrestiansen then you have multiple issues, what you described above is fixed then. Have you tried actually debugging your code, if not, please do. `await using var client` try removing `await` from your variable declaration and `await using var topic` remove `await` from that as well, it may or may not address your issue. – Trevor Apr 28 '22 at 13:10

0 Answers0