<div dir="ltr">I&#39;m still having this problem:<div><br></div><div>Any luck fixing it? &nbsp;<br><div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><a name="a18941638" style="font-size: 1em; "><h2 style="padding-top: 0.3em; padding-right: 0px; padding-bottom: 0.3em; padding-left: 0px; font-weight: bold; font-size: 1.2em; display: inline; margin-left: 0px; margin-right: 0.6em; ">
Re: how to close a connection in dotnet?</h2></a><a id="nabble.aflag18941638" href="javascript: void Nabble.setFlag(18941638);" title="Click to flag this post" style="font-size: 1em; "><img id="nabble.flag18941638" src="http://www.nabble.com/images/icon_unflagged.png" width="15" height="15" border="0" onmouseover="status = alt; return true;" onmouseout="status = defaultStatus; return true;" alt="Click to flag this post"></a>&nbsp;<span id="nabble.rating18941638"><img src="http://www.nabble.com/images/icon_star_blue.png" height="12" width="12" border="0"><img src="http://www.nabble.com/images/icon_star_blue.png" height="12" width="12" border="0"><img src="http://www.nabble.com/images/icon_star_blue.png" height="12" width="12" border="0"></span><div class="message-actions weak-color" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); color: rgb(102, 102, 102); font-size: 0.9em; margin-top: 0.45em; margin-bottom: 1.8em; ">
<p class="message-actions1" style="margin-top: 0px; margin-bottom: 0px; ">by&nbsp;<a href="http://www.nabble.com/user/UserProfile.jtp?user=1290996" rel="nofollow" target="_top" style="font-size: 1em; ">Hubert Plociniczak-2</a>&nbsp;<span class="weak-color" style="color: rgb(102, 102, 102); ">Aug 12, 2008; 06:30am</span>&nbsp;:: Rate this Message:&nbsp;<a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to mark as Spam" onmouseover="Nabble.mouseover(18941638,0); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,0); return false;" style="font-size: 1em; "><img id="nabble.spam18941638" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_blocked_gray.png" style="vertical-align: middle; "></a>&nbsp;<a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to rate as Poor Post" onmouseover="Nabble.mouseover(18941638,1); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,1); return false;" style="font-size: 1em; "><img id="nabble.star18941638-1" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_star_grey.png" style="vertical-align: middle; "></a><a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to rate as Below Average Post" onmouseover="Nabble.mouseover(18941638,2); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,2); return false;" style="font-size: 1em; "><img id="nabble.star18941638-2" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_star_grey.png" style="vertical-align: middle; "></a><a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to rate as Average Post" onmouseover="Nabble.mouseover(18941638,3); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,3); return false;" style="font-size: 1em; "><img id="nabble.star18941638-3" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_star_grey.png" style="vertical-align: middle; "></a><a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to rate as Above Average Post" onmouseover="Nabble.mouseover(18941638,4); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,4); return false;" style="font-size: 1em; "><img id="nabble.star18941638-4" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_star_grey.png" style="vertical-align: middle; "></a><a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to rate as Excellent Post" onmouseover="Nabble.mouseover(18941638,5); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,5); return false;" style="font-size: 1em; "><img id="nabble.star18941638-5" height="12" width="12" alt="" border="0" src="http://www.nabble.com/images/icon_star_grey.png" style="vertical-align: middle; "></a>&nbsp;<a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" title="Click to clear rating" onmouseover="Nabble.mouseover(18941638,-1); return true;" onmouseout="Nabble.mouseout(18941638); return true;" onclick="Nabble.clicked(18941638,-1); return false;" style="font-size: 1em; "><img id="nabble.star18941638-0" alt="" border="0" src="http://www.nabble.com/images/icon_clear_rating.png" style="vertical-align: middle; "></a>&nbsp;<span id="nabble.descriptor18941638">- Use ratings to moderate (<a title="Click for more info" href="http://www.nabble.com/help/Answer.jtp?id=16" style="font-size: 1em; ">?</a>)</span></p>
<p class="message-actions2" style="margin-top: 0.5em; margin-bottom: 0px; "><a href="http://www.nabble.com/forum/Reply.jtp?post=18941638" rel="nofollow" style="font-size: 1em; ">Reply</a>&nbsp;|&nbsp;<a href="http://www.nabble.com/user/SendEmail.jtp?type=pm&amp;post=18941638" target="_top" rel="nofollow" style="font-size: 1em; ">Reply to Author</a>&nbsp;|&nbsp;<a href="http://www.nabble.com/forum/PrintPost.jtp?post=18941638" rel="nofollow" target="_new" style="font-size: 1em; ">Print</a>&nbsp;|&nbsp;<a href="javascript: void Nabble.setView(&#39;newthreaded&#39;,18941638);" style="font-size: 1em; ">View Threaded</a>&nbsp;|&nbsp;<a href="http://www.nabble.com/Re%3A-how-to-close-a-connection-in-dotnet--p18941638.html" style="font-size: 1em; ">Show Only this Message</a></p>
</div><div class="message-details" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); margin-top: 0.75em; margin-right: 0px; margin-bottom: 0.75em; margin-left: 0px; ">
<div id="nabble.pending18941638" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); "></div><div class="message-text" id="nabble.msgtxt18941638" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); ">
<span>Hi Geoffrey,&nbsp;</span><br><br><span>I tried to reproduce your bug on Mono and everything was working&nbsp;</span><br><span>as expected.&nbsp;</span><br><br><span>Then I switched to .Net (native) and actually noticed your problem.&nbsp;</span><br>
<span>I guess there is something different with .Net environment (again)&nbsp;</span><br><span>and it does not behave as expected.&nbsp;</span><br><br><span>Thanks for reporting that!&nbsp;</span><br><span>I will fix that as soon as possible.&nbsp;</span><br>
<br><span>Hubert&nbsp;</span><br><br><span>Geoffrey Anderson wrote:</span><div class="shrinkable-quote" style="height: 160px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: hidden; overflow-y: hidden; ">
<br><span>&gt; Just a basic question on opening and closing the connection...&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; When I call this line of C# code using the .net library 1.4.0 :&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; mqConnection.Close();&nbsp;</span><br>
<span>&gt;&nbsp;</span><br><span>&gt; I quickly get this exception:&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; System.<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">ObjectDisposedException</b>&nbsp;was unhandled&nbsp;</span><br>
<span>&gt; &nbsp; Message=&quot;Cannot access a&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">disposed</b>&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">object</b>.\r\nObject name:&nbsp;</span><br>
<span>&gt; &#39;System.Net.Sockets.Socket&#39;.&quot;&nbsp;</span><br><span>&gt; &nbsp; Source=&quot;System&quot;&nbsp;</span><br><span>&gt; &nbsp;&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">ObjectName</b>=&quot;System.Net.Sockets.Socket&quot;&nbsp;</span><br>
<span>&gt; &nbsp; StackTrace:&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at System.Net.Sockets.TcpClient.set_ReceiveTimeout(Int32 value)&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">RabbitMQ</b>.Client.Impl.SocketFrameHandler_0_9.set_Timeout(Int32 value)&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">RabbitMQ</b>.Client.Impl.ConnectionBase.ClosingLoop()&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">RabbitMQ</b>.Client.Impl.ConnectionBase.MainLoop()&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at System.Threading.ThreadHelper.ThreadStart_Context(<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">Object</b>&nbsp;state)&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,&nbsp;</span><br><span>&gt; ContextCallback callback,&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">Object</b>&nbsp;state)&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;at System.Threading.ThreadHelper.ThreadStart()&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br><span>&gt; Here is the code which established my connection before I called the Close method.&nbsp;</span><br>
<span>&gt; &nbsp;&nbsp;</span><br><span>&gt; Is there a mistake in the way I set up the connection which might cause this socket&nbsp;</span><br><span>&gt; error? &nbsp;It seems to run fine and there are no exceptions except for the later Close&nbsp;</span><br>
<span>&gt; statement.&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; void OpenOutputQueue()&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqFactory = new ConnectionFactory();&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqFactory.Parameters.UserName = Cfg(&quot;MessageQueueUserName&quot;);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqFactory.Parameters.Password = Cfg(&quot;MessageQueuePassword&quot;);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqFactory.Parameters.VirtualHost = Cfg(&quot;MessageQueueVirtualHost&quot;, &quot;/&quot;);&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqFactory.Parameters.RequestedHeartbeat = 0;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //mqFactory.Parameters.RequestedHeartbeat = 20;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IProtocol mqProtocol = Protocols.FromEnvironment();&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqHost = Cfg(&quot;MessageQueueHost&quot;, &quot;localhost&quot;);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqConnection = mqFactory.CreateConnection(mqProtocol, mqHost);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqModel = mqConnection.CreateModel();&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqTicket = mqModel.AccessRequest(Cfg(&quot;MessageQueueRealm&quot;));&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqExchange = Cfg(&quot;MessageQueueExchange&quot;);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqModel.ExchangeDeclare(mqTicket, mqExchange, ExchangeType.Direct);&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqQueueName = Cfg(&quot;MessageQueueName&quot;);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqModel.QueueDeclare(mqTicket, mqQueueName, false);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqRoutingKey = Cfg(&quot;MessageQueueRoutingKey&quot;);&nbsp;</span><br>
<span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqModel.QueueBind(mqTicket, mqQueueName, mqExchange, mqRoutingKey,&nbsp;</span><br><span>&gt; false, null);&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mqConnection.AutoClose = false;&nbsp;</span><br><span>&gt; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;</span><br>
<span>&gt;&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; Sorry to waste time if I missed something in the manuals.&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; Thanks for reading.&nbsp;</span><br><span>&gt;&nbsp;</span><br>
<span>&gt; Geoffrey Anderson&nbsp;</span><br><span>&gt;&nbsp;</span><br><span>&gt; _______________________________________________&nbsp;</span><br><span>&gt;&nbsp;<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">rabbitmq</b>-<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">discuss</b>&nbsp;mailing list&nbsp;</span><br>
<span>&gt;&nbsp;</span><a href="http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=18941638&amp;i=0" target="_top" rel="nofollow" style="font-size: 1em; text-decoration: none; "><span><b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">rabbitmq</b>-<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">discuss</b>@...</span></a><span>&nbsp;</span><br>
<span>&gt;&nbsp;</span><a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_top" rel="nofollow" style="font-size: 1em; text-decoration: none; "><span>http://lists.<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">rabbitmq</b>.com/cgi-bin/mailman/listinfo/<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">rabbitmq</b>-<b class="highlight" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 102); background-position: initial initial; ">discuss</b></span></a><br>
<span>&gt;&nbsp;</span><br><span>&gt; &nbsp;</span></div><div class="shrink-quote" style="border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); ">
<span>...</span>&nbsp;[<a href="http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#" style="font-size: 80%; text-decoration: none; ">show rest of quote</a>]</div><br><span>--&nbsp;</span><br><span>&nbsp;[][][] Hubert Plociniczak&nbsp;</span><br>
<span>&nbsp; &nbsp;[][] LShift Ltd&nbsp;</span><br><span>&nbsp;[] &nbsp;[] <a href="http://www.lshift.net">www.lshift.net</a>&nbsp;</span><br><br></div></div></span></div></div></div>