I am using ZMQ for our project and wrote a factory that creates ZMQ Clients based on type of the message required. However, an issue I find is that, sometimes TrySendFrame returns false and most of the times it returns true. Any way this can be corrected?
The data remains same, the code remains same, address and everything remains same but occasionally it returns false from TrySendFrame.
I could not identify why it is failing. After using SendFrame instead of using TrySendFrame it gets blocked forever in some cases.
public ZmqPushClient(string address, bool isByteData = false) : base(address, isByteData)
{
if (Address.Contains("*"))
{
Address = "@" + Address;
_pushSocket = new PushSocket(Address);
}
else
{
_pushSocket = new PushSocket(Address);
}
}
public bool Push(string message)
{
lock (_locker)
{
TimeSpan timeout = TimeSpan.FromMilliseconds(1000);
_logger.Debug("Pushing : " + message);
bool success = _pushSocket.TrySendFrame(timeout, message);
if (success)
{
_logger.Info("Success : " + success);
}
else
{
_logger.Error("Could not push to URL : " + Address);
}
return success;
}
}
I expect the messages to be sent. At certain times it works perfectly fine, but sometimes I see error in logs which is a problem as a failed send has a good impact on my application.