title: Messages are not delivered after reconnect over ROUTER-ROUTER in NetMQ
body: <p>I have a problem with ROUTER-ROUTER communication with <strong>NetMQ</strong>.</p>
  
  <p>Two applications, Client and Server. Both using ROUTER sockets. Client ROUTER socket is not setting it's identity explicitly, only Server.</p>
  
  <p>After the connection established first time, messages are routed from client (ROUTER) to server (ROUTER).
  But as soon as client calls Disconnect() and then Connect() again (after a very short time, i.e. 10 msec), the server is not receiving messages any more.</p>
  
  <p>What is interesting, that reconnection works fine if <strong>ZeroMq</strong> C# lib is used.</p>
  
  <p>Is it a known issue or I'm doing something wrong here?</p>
  
  <p>Minimal code to reproduce the issue:</p>
  
  <pre><code>  public class PureNetMQ
    {
      private static readonly byte[] ServerIdentity = {1, 2, 3};
      private static readonly byte[] ClientIdentity = {1, 2, 4};
      private static readonly string Address = "tcp://127.0.0.1:5000";
  
      private static void Main(string[] args)
      {
        var cancellationTokenSource = new CancellationTokenSource();
        Task.Factory.StartNew(_ =&gt; RunServer(cancellationTokenSource.Token), cancellationTokenSource.Token, TaskCreationOptions.LongRunning);
        Thread.Sleep(TimeSpan.FromSeconds(2));
  
        RunClient();
  
        Console.WriteLine("Done");
        Console.ReadLine();
        cancellationTokenSource.Cancel(true);
      }
  
      private static void RunClient()
      {
        using (var context = NetMQContext.Create())
        {
          using (NetMQSocket socket = context.CreateRouterSocket())
          {
            //socket.Options.Identity = Guid.NewGuid().ToByteArray();
            //socket.Options.RouterMandatory = true;
            socket.Options.Linger = TimeSpan.Zero;
  
            socket.Connect(Address);
  
            Thread.Sleep(TimeSpan.FromSeconds(2));
  
            socket.SendMore(ServerIdentity);
            socket.SendMore(Encoding.UTF8.GetBytes(""));
            socket.Send(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()));
            Console.WriteLine("Message sent...");
  
            socket.Disconnect(Address);
            Thread.Sleep(TimeSpan.FromSeconds(5));
            Console.WriteLine("Disconnected");
  
            //socket.Options.Identity = Guid.NewGuid().ToByteArray();
            socket.Connect(Address);
            Thread.Sleep(TimeSpan.FromSeconds(5));
            Console.WriteLine("Reconnected");
  
  
            socket.SendMore(ServerIdentity);
            socket.SendMore(Encoding.UTF8.GetBytes(""));
            socket.Send(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()));
            Console.WriteLine("Message sent...");
  
            Thread.Sleep(TimeSpan.FromSeconds(5));
          }
        }
      }
  
      private static void RunServer(CancellationToken token)
      {
        using (var context = NetMQContext.Create())
        {
          using (var socket = context.CreateRouterSocket())
          {
            socket.Options.Identity = ServerIdentity;
            //socket.Options.RouterMandatory = true;
            socket.Options.Linger = TimeSpan.Zero;
  
            socket.Bind(Address);
  
            while (!token.IsCancellationRequested)
            {
              var message = socket.ReceiveMessage();
  
              for (var i = 2; i &lt; message.FrameCount; i++)
              {
                Console.WriteLine("Message: {0}", Encoding.UTF8.GetString(message[i].Buffer));
              }
            }
          }
        }
      }
    }
  </code></pre>