[rabbitmq-discuss] how to close a connection in dotnet?

Benjamin Polidore polidore at gmail.com
Tue Oct 7 03:35:26 BST 2008


I'm still having this problem:
Any luck fixing it?

Re: how to close a connection in dotnet?[image: Click to flag this
post]<javascript: void Nabble.setFlag(18941638);>


by Hubert Plociniczak-2<http://www.nabble.com/user/UserProfile.jtp?user=1290996>
 Aug 12, 2008; 06:30am :: Rate this Message:
<http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#>
 <http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#><http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#><http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#><http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#><http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#>
 <http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#>
 - Use ratings to moderate (? <http://www.nabble.com/help/Answer.jtp?id=16>)

Reply <http://www.nabble.com/forum/Reply.jtp?post=18941638> | Reply to
Author <http://www.nabble.com/user/SendEmail.jtp?type=pm&post=18941638> |
Print <http://www.nabble.com/forum/PrintPost.jtp?post=18941638> | View
Threaded <javascript: void Nabble.setView('newthreaded',18941638);> | Show
Only this Message<http://www.nabble.com/Re%3A-how-to-close-a-connection-in-dotnet--p18941638.html>
Hi Geoffrey,

I tried to reproduce your bug on Mono and everything was working
as expected.

Then I switched to .Net (native) and actually noticed your problem.
I guess there is something different with .Net environment (again)
and it does not behave as expected.

Thanks for reporting that!
I will fix that as soon as possible.

Hubert

Geoffrey Anderson wrote:
> Just a basic question on opening and closing the connection...
>
> When I call this line of C# code using the .net library 1.4.0 :
>
> mqConnection.Close();
>
> I quickly get this exception:
>
> System.*ObjectDisposedException* was unhandled
>   Message="Cannot access a *disposed* *object*.\r\nObject name:
> 'System.Net.Sockets.Socket'."
>   Source="System"
>   *ObjectName*="System.Net.Sockets.Socket"
>   StackTrace:
>        at System.Net.Sockets.TcpClient.set_ReceiveTimeout(Int32 value)
>        at *RabbitMQ*.Client.Impl.SocketFrameHandler_0_9.set_Timeout(Int32
value)
>        at *RabbitMQ*.Client.Impl.ConnectionBase.ClosingLoop()
>        at *RabbitMQ*.Client.Impl.ConnectionBase.MainLoop()
>        at System.Threading.ThreadHelper.ThreadStart_Context(*Object*
 state)
>        at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext,
> ContextCallback callback, *Object* state)
>        at System.Threading.ThreadHelper.ThreadStart()
>
>
>
> Here is the code which established my connection before I called the Close
method.
>
> Is there a mistake in the way I set up the connection which might cause
this socket
> error?  It seems to run fine and there are no exceptions except for the
later Close
> statement.
>
>
>         void OpenOutputQueue()
>         {
>             mqFactory = new ConnectionFactory();
>             mqFactory.Parameters.UserName = Cfg("MessageQueueUserName");
>             mqFactory.Parameters.Password = Cfg("MessageQueuePassword");
>             mqFactory.Parameters.VirtualHost =
Cfg("MessageQueueVirtualHost", "/");
>             mqFactory.Parameters.RequestedHeartbeat = 0;
>             //mqFactory.Parameters.RequestedHeartbeat = 20;
>             IProtocol mqProtocol = Protocols.FromEnvironment();
>             mqHost = Cfg("MessageQueueHost", "localhost");
>             mqConnection = mqFactory.CreateConnection(mqProtocol,
mqHost);
>             mqModel = mqConnection.CreateModel();
>             mqTicket = mqModel.AccessRequest(Cfg("MessageQueueRealm"));
>             mqExchange = Cfg("MessageQueueExchange");
>             mqModel.ExchangeDeclare(mqTicket, mqExchange,
ExchangeType.Direct);
>             mqQueueName = Cfg("MessageQueueName");
>             mqModel.QueueDeclare(mqTicket, mqQueueName, false);
>             mqRoutingKey = Cfg("MessageQueueRoutingKey");
>             mqModel.QueueBind(mqTicket, mqQueueName, mqExchange,
mqRoutingKey,
> false, null);
>             mqConnection.AutoClose = false;
>         }
>
>
>
> Sorry to waste time if I missed something in the manuals.
>
> Thanks for reading.
>
> Geoffrey Anderson
>
> _______________________________________________
> *rabbitmq*-*discuss* mailing list
> *rabbitmq*-*discuss*@...<http://www.nabble.com/user/SendEmail.jtp?type=post&post=18941638&i=0>

> http://lists.*rabbitmq*.com/cgi-bin/mailman/listinfo/*rabbitmq*-*discuss*<http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss>
>
>
... [show rest of
quote<http://www.nabble.com/how-to-close-a-connection-in-dotnet--td18935278.html#>
]

-- 
 [][][] Hubert Plociniczak
   [][] LShift Ltd
 []  [] www.lshift.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20081006/1d9e9c9f/attachment.htm 


More information about the rabbitmq-discuss mailing list