<p>Hi Dave, although counterintuitive the documentation of the .NET client states that explicitly. The connection closure/disposal is not idempotent, i.e. you shall not call it twice.</p>
<div class="gmail_quote">On Dec 29, 2011 1:41 AM, &quot;Dave Stevens&quot; &lt;<a href="mailto:daverstevens@gmail.com">daverstevens@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am getting the following exception when disposing a connection. I<br>
had previously noticed this when going from RabbitMQ Client 2.5.1 to<br>
2.7.0 which caused me to back out the update. I ended up going to<br>
2.7.1 because I thought I found a shutdown issue in my own code. The<br>
exception did not present itself again until I started testing some<br>
reconnect logic. I first noticed it again after simply pulling the<br>
plug on my network.<br>
<br>
System.ObjectDisposedException: Cannot access a disposed object.<br>
Object name: &#39;System.Net.Sockets.Socket&#39;.<br>
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel<br>
optionLevel, SocketOptionName optionName, Object optionValue)<br>
at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.Close()<br>
at RabbitMQ.Client.Impl.ConnectionBase.FinishClose()<br>
at RabbitMQ.Client.Impl.ConnectionBase.HeartbeatWriteLoop()<br>
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br>
at System.Threading.ExecutionContext.runTryCode(Object userData)<br>
at<br>
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode<br>
code, CleanupCode backoutCode, Object userData)<br>
at System.Threading.ExecutionContext.RunInternal(ExecutionContext<br>
executionContext, ContextCallback callback, Object state)<br>
at System.Threading.ExecutionContext.Run(ExecutionContext<br>
executionContext, ContextCallback callback, Object state, Boolean<br>
ignoreSyncCtx)<br>
at System.Threading.ExecutionContext.Run(ExecutionContext<br>
executionContext, ContextCallback callback, Object state)<br>
at System.Threading.ThreadHelper.ThreadStart()<br>
<br>
This code is reproducible consistently with the following:<br>
<br>
using System;<br>
using System.Threading;<br>
using NUnit.Framework;<br>
using RabbitMQ.Client;<br>
using RabbitMQ.Client.Framing.v0_9;<br>
<br>
namespace BT.ThirdPartyProxy.Functional.Test.FunctionalTests<br>
{<br>
    [TestFixture]<br>
    public class TestingObjectDispositionException<br>
    {<br>
        [Test(Description = &quot;ObjectDispositionException&quot;)]<br>
        public void TestFail()<br>
        {<br>
            var cf = new ConnectionFactory<br>
                         {<br>
                             HostName = INSERT_IP_HERE,<br>
                             Port = 5672,<br>
                             RequestedHeartbeat = 2<br>
                         };<br>
            using (var connection = cf.CreateConnection())<br>
            using (var model = connection.CreateModel())<br>
            {<br>
                Thread.Sleep(TimeSpan.FromSeconds(1));<br>
                model.Close(Constants.ReplySuccess, &quot;Goodbye&quot;);<br>
                connection.Close(Constants.ReplySuccess, &quot;Goodbye&quot;);<br>
                Thread.Sleep(TimeSpan.FromSeconds(1));<br>
            }<br>
        }<br>
    }<br>
}<br>
<br>
<br>
I am using RabbitMQ.Client.dll 2.7.1.0 in .NET 4.0 app on Windows<br>
server 2003 going against RabbitMQ 2.7.0 running on Ubuntu.<br>
<br>
Status of node rabbit@xxx ...<br>
[{pid,1344},<br>
 {running_applications,<br>
     [{rabbitmq_management,&quot;RabbitMQ Management Console&quot;,&quot;2.7.0&quot;},<br>
      {rabbitmq_management_agent,&quot;RabbitMQ Management Agent&quot;,&quot;2.7.0&quot;},<br>
      {amqp_client,&quot;RabbitMQ AMQP Client&quot;,&quot;2.7.0&quot;},<br>
      {rabbit,&quot;RabbitMQ&quot;,&quot;2.7.0&quot;},<br>
      {os_mon,&quot;CPO  CXC 138 46&quot;,&quot;2.2.5&quot;},<br>
      {sasl,&quot;SASL  CXC 138 11&quot;,&quot;2.1.9.3&quot;},<br>
      {rabbitmq_mochiweb,&quot;RabbitMQ Mochiweb Embedding&quot;,&quot;2.7.0&quot;},<br>
      {webmachine,&quot;webmachine&quot;,&quot;1.7.0-rmq2.7.0-hg&quot;},<br>
      {mochiweb,&quot;MochiMedia Web Server&quot;,&quot;1.3-rmq2.7.0-git&quot;},<br>
      {inets,&quot;INETS  CXC 138 49&quot;,&quot;5.5.2&quot;},<br>
      {mnesia,&quot;MNESIA  CXC 138 12&quot;,&quot;4.4.17&quot;},<br>
      {stdlib,&quot;ERTS  CXC 138 10&quot;,&quot;1.17.3&quot;},<br>
      {kernel,&quot;ERTS  CXC 138 10&quot;,&quot;2.14.3&quot;}]},<br>
 {os,{unix,linux}},<br>
 {erlang_version,<br>
     &quot;Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:8:8] [rq:8]<br>
[async-threads:30] [kernel-poll:true]\n&quot;},<br>
 {memory,<br>
     [{total,31177024},<br>
      {processes,11828776},<br>
      {processes_used,11772888},<br>
      {system,19348248},<br>
      {atom,1355273},<br>
      {atom_used,1339382},<br>
      {binary,84928},<br>
      {code,14547474},<br>
      {ets,1099944}]},<br>
 {vm_memory_high_watermark,0.39999999995232727},<br>
 {vm_memory_limit,<a href="tel:5034326425" value="+15034326425">5034326425</a>}]<br>
...done.<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</blockquote></div>