zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

TryRecieveMultipartBytes blocks even with timeout set #760

Closed tschombe closed 6 years ago

tschombe commented 6 years ago

Environment

NetMQ Version:    4.0.0.1
Operating System: Windows 10
.NET Version:     4.6

Expected behaviour

I am using a response socket and waiting for a request with resSocket.TryRecieveMultipartBytes() with a timeout as the first parameter

I would expect the method to return after the timeout expires either with false as return code or with a timeout exception, but the method blocks indefinitely

Actual behaviour

TryRecieveMultipartBytes of responseSocket blocks even if a timeout is passed

Steps to reproduce the behaviour

using (resSocket = new ResponseSocket(resAddress))
{
   while (true)
    {
         List<byte[]> recieveBytes = new List<byte[]>();
        if (resSocket.TryReceiveMultipartBytes(new TimeSpan(1000), ref recieveBytes))
        {
            Console.WriteLine("DATA RECIEVED");
        }
    }
}
drewnoakes commented 6 years ago

I think the problem is new TimeSpan(1000). That's 1000 ticks, which isn't very long. Try TimeSpan.FromSeconds(1000) or something like that.

tschombe commented 6 years ago

oops, my bad I already figured that out during writing the reproduce behavior. But thanks for your response, I will close the issue