<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, "Dave Stevens" <<a href="mailto:daverstevens@gmail.com">daverstevens@gmail.com</a>> 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: 'System.Net.Sockets.Socket'.<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 = "ObjectDispositionException")]<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, "Goodbye");<br>
connection.Close(Constants.ReplySuccess, "Goodbye");<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,"RabbitMQ Management Console","2.7.0"},<br>
{rabbitmq_management_agent,"RabbitMQ Management Agent","2.7.0"},<br>
{amqp_client,"RabbitMQ AMQP Client","2.7.0"},<br>
{rabbit,"RabbitMQ","2.7.0"},<br>
{os_mon,"CPO CXC 138 46","2.2.5"},<br>
{sasl,"SASL CXC 138 11","2.1.9.3"},<br>
{rabbitmq_mochiweb,"RabbitMQ Mochiweb Embedding","2.7.0"},<br>
{webmachine,"webmachine","1.7.0-rmq2.7.0-hg"},<br>
{mochiweb,"MochiMedia Web Server","1.3-rmq2.7.0-git"},<br>
{inets,"INETS CXC 138 49","5.5.2"},<br>
{mnesia,"MNESIA CXC 138 12","4.4.17"},<br>
{stdlib,"ERTS CXC 138 10","1.17.3"},<br>
{kernel,"ERTS CXC 138 10","2.14.3"}]},<br>
{os,{unix,linux}},<br>
{erlang_version,<br>
"Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:8:8] [rq:8]<br>
[async-threads:30] [kernel-poll:true]\n"},<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>