<div dir="ltr">I'm still having this problem:<div><br></div><div>Any luck fixing it? <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> <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 <a href="http://www.nabble.com/user/UserProfile.jtp?user=1290996" rel="nofollow" target="_top" style="font-size: 1em; ">Hubert Plociniczak-2</a> <span class="weak-color" style="color: rgb(102, 102, 102); ">Aug 12, 2008; 06:30am</span> :: Rate this Message: <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> <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> <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> <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> | <a href="http://www.nabble.com/user/SendEmail.jtp?type=pm&post=18941638" target="_top" rel="nofollow" style="font-size: 1em; ">Reply to Author</a> | <a href="http://www.nabble.com/forum/PrintPost.jtp?post=18941638" rel="nofollow" target="_new" style="font-size: 1em; ">Print</a> | <a href="javascript: void Nabble.setView('newthreaded',18941638);" style="font-size: 1em; ">View Threaded</a> | <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, </span><br><br><span>I tried to reproduce your bug on Mono and everything was working </span><br><span>as expected. </span><br><br><span>Then I switched to .Net (native) and actually noticed your problem. </span><br>
<span>I guess there is something different with .Net environment (again) </span><br><span>and it does not behave as expected. </span><br><br><span>Thanks for reporting that! </span><br><span>I will fix that as soon as possible. </span><br>
<br><span>Hubert </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>> Just a basic question on opening and closing the connection... </span><br><span>> </span><br><span>> When I call this line of C# code using the .net library 1.4.0 : </span><br><span>> </span><br><span>> mqConnection.Close(); </span><br>
<span>> </span><br><span>> I quickly get this exception: </span><br><span>> </span><br><span>> 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> was unhandled </span><br>
<span>> Message="Cannot access a <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> <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: </span><br>
<span>> 'System.Net.Sockets.Socket'." </span><br><span>> Source="System" </span><br><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; ">ObjectName</b>="System.Net.Sockets.Socket" </span><br>
<span>> StackTrace: </span><br><span>> at System.Net.Sockets.TcpClient.set_ReceiveTimeout(Int32 value) </span><br><span>> at <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) </span><br>
<span>> at <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() </span><br>
<span>> at <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() </span><br>
<span>> 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> state) </span><br>
<span>> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, </span><br><span>> ContextCallback callback, <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> state) </span><br>
<span>> at System.Threading.ThreadHelper.ThreadStart() </span><br><span>> </span><br><span>> </span><br><span>> </span><br><span>> Here is the code which established my connection before I called the Close method. </span><br>
<span>> </span><br><span>> Is there a mistake in the way I set up the connection which might cause this socket </span><br><span>> error? It seems to run fine and there are no exceptions except for the later Close </span><br>
<span>> statement. </span><br><span>> </span><br><span>> </span><br><span>> void OpenOutputQueue() </span><br><span>> { </span><br><span>> mqFactory = new ConnectionFactory(); </span><br>
<span>> mqFactory.Parameters.UserName = Cfg("MessageQueueUserName"); </span><br><span>> mqFactory.Parameters.Password = Cfg("MessageQueuePassword"); </span><br><span>> mqFactory.Parameters.VirtualHost = Cfg("MessageQueueVirtualHost", "/"); </span><br>
<span>> mqFactory.Parameters.RequestedHeartbeat = 0; </span><br><span>> //mqFactory.Parameters.RequestedHeartbeat = 20; </span><br><span>> IProtocol mqProtocol = Protocols.FromEnvironment(); </span><br>
<span>> mqHost = Cfg("MessageQueueHost", "localhost"); </span><br><span>> mqConnection = mqFactory.CreateConnection(mqProtocol, mqHost); </span><br><span>> mqModel = mqConnection.CreateModel(); </span><br>
<span>> mqTicket = mqModel.AccessRequest(Cfg("MessageQueueRealm")); </span><br><span>> mqExchange = Cfg("MessageQueueExchange"); </span><br><span>> mqModel.ExchangeDeclare(mqTicket, mqExchange, ExchangeType.Direct); </span><br>
<span>> mqQueueName = Cfg("MessageQueueName"); </span><br><span>> mqModel.QueueDeclare(mqTicket, mqQueueName, false); </span><br><span>> mqRoutingKey = Cfg("MessageQueueRoutingKey"); </span><br>
<span>> mqModel.QueueBind(mqTicket, mqQueueName, mqExchange, mqRoutingKey, </span><br><span>> false, null); </span><br><span>> mqConnection.AutoClose = false; </span><br><span>> } </span><br>
<span>> </span><br><span>> </span><br><span>> </span><br><span>> Sorry to waste time if I missed something in the manuals. </span><br><span>> </span><br><span>> Thanks for reading. </span><br><span>> </span><br>
<span>> Geoffrey Anderson </span><br><span>> </span><br><span>> _______________________________________________ </span><br><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> mailing list </span><br>
<span>> </span><a href="http://www.nabble.com/user/SendEmail.jtp?type=post&post=18941638&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> </span><br>
<span>> </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>> </span><br><span>> </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> [<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>-- </span><br><span> [][][] Hubert Plociniczak </span><br>
<span> [][] LShift Ltd </span><br><span> [] [] <a href="http://www.lshift.net">www.lshift.net</a> </span><br><br></div></div></span></div></div></div>