title: Reconnecting to socket.io server takes long time after receiving messages using SocketIoClientDotNet
body: <p>I'm developing a plugin for Grasshopper for Rhino which uses a .NET framework with C# and I have a problem when reconnecting to a socket.io 1.4.5 server. I'm using <a href="https://github.com/Quobject/SocketIoClientDotNet" rel="nofollow noreferrer">SocketIoClientDotNet 0.9.13</a> to connect to a server and it works fine if I just want to connect/disconnect to a server but I have a problem reconnecting to a server after I received a message using an event taking a lot of time to reconnect.</p>
  <p>Depends on the number of messages I received by the event during the connection, after I close and make a new connection it takes more than a minute (sometimes more than 10 mins if there are a lot of messages received) for the new connection.</p>
  <p>Could anybody tell what is going wrong?</p>
  <p>The code is written as follows:</p>
  <pre><code>Quobject.SocketIoClientDotNet.Client.Socket socket;
  
  private System.Threading.ManualResetEvent manualResetEvent = null;
  private bool currentState = false;
  public object output = null;
  public bool connected = false;
  
  private Quobject.SocketIoClientDotNet.Client.IO.Options CreateOptions()
  {
    Quobject.SocketIoClientDotNet.Client.IO.Options op = new Quobject.SocketIoClientDotNet.Client.IO.Options();
    op.AutoConnect = true;
    op.Reconnection = true;
    op.ReconnectionAttempts = 5;
    op.ReconnectionDelay = 5;
    op.Timeout = 20;
    op.Secure = true;
    op.ForceNew = true;
    op.Multiplex = true;
    return op;
  }
  
  private void ConnectToSocket(bool b, string address){
    if(currentState != b){
      if(b &amp;&amp; !connected){
          manualResetEvent = new System.Threading.ManualResetEvent(false);
  
          var options = CreateOptions();
          socket = IO.Socket(address, options);
  
          socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT, () =&gt;
            {
  
            connected = true;
            Print(&quot;connected&quot;);
            manualResetEvent.Set();
            });
  
          socket.On(&quot;slider_message&quot;, (data) =&gt;
            {
            if(data != null){
              var jobject = data as JToken;
              try{
                var sliderValue = jobject.Value&lt;string&gt;(&quot;slider&quot;);
                output = sliderValue;
              }catch{
  
              }
            }
  
            manualResetEvent.Set();
            });
       
          socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_DISCONNECT, () =&gt;
            {
  
            connected = false;
            Print(&quot;disconnected&quot;);
  
            manualResetEvent.Set();
            });
  
          Print(&quot;connecting...&quot;);
  
          manualResetEvent.WaitOne();
      }else{
        if(socket != null &amp; connected){
          manualResetEvent = new System.Threading.ManualResetEvent(false);
  
          Print(&quot;disconnecting...&quot;);
          socket.Close();
  
          manualResetEvent.WaitOne();
          socket = null;
        }
      }
    }
  
    currentState = b;
  }
  </code></pre>