I'm using the C# data binding for nanomsg. I have an external program that is sending Google Protocol Buffer messages on the url ipc://report_data and my subscriber connects to that same exact url. So, I would expect my subscriber to be able to retrieve any data being sent on that url, however, it is not. I use the function Receive() and nothing ever comes through. There is only one type of message coming through on that URL so I'm not concerned about the topic. Does anyone with experience with nanomsg know how to read ANY data that comes in on the transport url, regardless of topic?
This is the code for my subscriber and receiving messages:
public static void CreateSubscriber(string url, string topic)
{
Console.WriteLine("\nCreating new subscriber with topic {0} and url {1}.", topic, url);
var subscriber = new SubscribeSocket();
subscriber.Connect(url);
var sw = Stopwatch.StartNew();
while (sw.Elapsed.TotalSeconds < 5000)
{
if (sw.Elapsed.TotalSeconds % 3 == 0)
{
Console.WriteLine("Checking for new data.");
var streamOutput = ReceiveProtoBufferMessage(subscriber, topic);
}
}
sw.Stop();
Thread.Sleep(1);
Console.WriteLine("Disposing subscriber.");
subscriber.Dispose();
}
static byte[] ReceiveProtoBufferMessage(SubscribeSocket s, string topic)
{
byte[] data = null;
try
{
data = s.Receive();
Console.WriteLine("Received data.");
}
catch
{
Console.WriteLine("Couldn't receive data.");
}
if (data != null)
{
Console.WriteLine("Data is not null.");
}
else
{
Console.WriteLine("Null data");
}
return data;
}