Open AnudeepGarge opened 2 years ago
I am not able to recreate the problem with the code you have described. And it also seems very unlikely that it would ever hang. However since your code would stop immediately after startup, it is quite likely that the logging framework had not yet processed the last log entry before shutdown. I have altered your code to make it compile, and using the console output it work like a charm always. See code snippet below, which will actually compile.
using System.Text; using NetMQ; using NetMQ.Sockets;
class Issue1002 { static void Main() { Console.WriteLine("Creating..."); NetMQSocket NetMqSocket = CreateDealer();
var Pooler = new NetMQPoller { NetMqSocket };
NetMqSocket.ReceiveReady += OnReady;
Pooler.RunAsync();
Console.WriteLine("Created");
Pooler.Dispose();
}
static NetMQSocket CreateDealer()
{
var zmqSocket = new DealerSocket();
zmqSocket.Options.Identity = Encoding.Unicode.GetBytes(Guid.NewGuid().ToString());
return zmqSocket;
}
static void OnReady(object? sender, NetMQSocketEventArgs e)
{
Console.WriteLine("on ready");
}
}
Environment
Expected behaviour
Dealer must not hang in any circumstances.
Actual behaviour
Dealer hangs intermittently
Steps to reproduce the behaviour
The below code when used in a foreground thread hangs intermittently. I could not reproduce it all the time but I could see the log pattern where "Creating..." entered but ("Created" did not appear.
main () { logger.Log("Creating...") NetMQSocket NetMqSocket = CreateDealer() Pooler = new NetMQPoller { NetMqSocket };
logger.Log("Created") }
private static NetMQSocket CreateDealerSocket() { var zmqSocket = new DealerSocket(); zmqSocket.Options.Identity = Encoding.Unicode.GetBytes(Guid.NewGuid().ToString());