Hi Everyone,
I have been trying to diagnose this, but I am not clever enough to find out what is going on inside NetMQ. I have cloned the NetMQ and AsyncIO repositories to try and work out where the open files are coming from.
I split the code out so the client and server are 2 different applications. I changed the client to use Dispose instead of disconnect and slowed down the rate at which it creates sockets so It doesn't crash straight away.
If I run the Client for a while the number of open files increases and seem to be fairly evenly split between ones that are labeled mono, ThreadPool and IO. If I close the client, the number of open files for the server stays the same indefinitely until I close the server. As soon as the server is closed the number of open files goes to 0.
I can't believe no one else has seen this problem if they have a long running server and clients that come and go (or even poor network conditions). Or could it be specific to Mono on Linux?
Thanks
Dean
Here is my Server code,
using System;
using NetMQ;
using System.Threading;
namespace Socket_Server
{
class MainClass
{
public static void Main (string[] args)
{
using (var context = NetMQContext.Create ())
using (var router = context.CreateResponseSocket ())
{
router.Options.Linger = TimeSpan.Zero;
router.Options.DisableTimeWait = true;
router.Bind("tcp://127.0.0.1:5556");
for (int i = 0; i < 100000; i++) {
Thread.Sleep (TimeSpan.FromSeconds (1));
}
}
}
}
}
Any my Client Code
using System;
using NetMQ;
using System.Threading.Tasks;
using System.Threading;
namespace Socket_Test
{
class MainClass
{
public static void Main (string[] args)
{
using (var context = NetMQContext.Create ()) {
for (int i = 0; i < 100000; i++) {
using (var request = context.CreateRequestSocket ()) {
request.Options.Linger = TimeSpan.Zero;
request.Connect ("tcp://127.0.0.1:5556");
//Thread.Sleep (TimeSpan.FromSeconds (2));
Console.WriteLine ("Sending message");
//request.Send ("1", sendMore: false);
//request.Disconnect ("tcp://127.0.0.1:5556");
Console.WriteLine ("Socket Closed");
Thread.Sleep (TimeSpan.FromMilliseconds (500));
}
}
}
}
}
}