You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by anujjain <an...@gmail.com> on 2009/01/08 10:46:46 UTC

Error writing to broker. Transport connection is closed.

Hi, I new to ActiveMQ. I trying to build a .NET client by using NMS 1.1 for
ActiveMQ 4.1.1. I wrote a simple publisher program by sending two messages.
I worked fine then but if I give a Sleep time of 60000(1 min). First message
is sent fine, butbefore sending the second message I am getting following
error:
========================
System.InvalidOperationException: Error writing to broker.  Transport
connection is closed.
   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Oneway(Command command)
: Transport connection error: Error writing to broker.  Transport connection
is closed.
========================
I did the same exercise with Java API, and it was working fine. Following is
the exact code in C#
        
        const string TOPIC_NAME = "SampleSubscriptionTopic";
        const string BROKER = "tcp://localhost:61616";
        const string CLIENT_ID = "ActiveMqFirstSubscriber1";
        const string CONSUMER_ID = "ActiveMqFirstSubscriber1";

        static void Main(string[] args)
        {
               IConnectionFactory factory = new ConnectionFactory(BROKER);
                IConnection con = factory.CreateConnection();
                con.Start();
                ISession sess = con.CreateSession();
                ActiveMQTopic topic = new ActiveMQTopic(TOPIC_NAME);
                IMessageProducer prod = sess.CreateProducer(topic);
                for (int i = 0; i < 2; i++)
                {
                    ActiveMQTextMessage message = new
ActiveMQTextMessage("this is from C# client " + i);
                    prod.Send(message);
                    Console.WriteLine("Message number "+i+" send");
                    Thread.Sleep(60000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }

        }
Can any one please suggest me what is missing in the above code?
-- 
View this message in context: http://www.nabble.com/Error-writing-to-broker.--Transport-connection-is-closed.-tp21348706p21348706.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Error writing to broker. Transport connection is closed.

Posted by Jim Gomes <e....@gmail.com>.
I've never worked with ActiveMQ 4.1 series.  I would only be able to try
this against the 5.1.0 or higher version.  I tend to stay with the latest
version of ActiveMQ.  This issue would need to be narrowed down to whether
it is a client or broker issue.  Could you try this test against ActiveMQ
5.2.0?  If it still fails with that version, it is most likely an NMS issue.

On Thu, Jan 8, 2009 at 1:46 AM, anujjain <an...@gmail.com> wrote:

>
> Hi, I new to ActiveMQ. I trying to build a .NET client by using NMS 1.1 for
> ActiveMQ 4.1.1. I wrote a simple publisher program by sending two messages.
> I worked fine then but if I give a Sleep time of 60000(1 min). First
> message
> is sent fine, butbefore sending the second message I am getting following
> error:
> ========================
> System.InvalidOperationException: Error writing to broker.  Transport
> connection is closed.
>   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Oneway(Command command)
> : Transport connection error: Error writing to broker.  Transport
> connection
> is closed.
> ========================
> I did the same exercise with Java API, and it was working fine. Following
> is
> the exact code in C#
>
>        const string TOPIC_NAME = "SampleSubscriptionTopic";
>        const string BROKER = "tcp://localhost:61616";
>        const string CLIENT_ID = "ActiveMqFirstSubscriber1";
>        const string CONSUMER_ID = "ActiveMqFirstSubscriber1";
>
>        static void Main(string[] args)
>        {
>               IConnectionFactory factory = new ConnectionFactory(BROKER);
>                IConnection con = factory.CreateConnection();
>                con.Start();
>                ISession sess = con.CreateSession();
>                ActiveMQTopic topic = new ActiveMQTopic(TOPIC_NAME);
>                IMessageProducer prod = sess.CreateProducer(topic);
>                for (int i = 0; i < 2; i++)
>                {
>                    ActiveMQTextMessage message = new
> ActiveMQTextMessage("this is from C# client " + i);
>                    prod.Send(message);
>                    Console.WriteLine("Message number "+i+" send");
>                    Thread.Sleep(60000);
>                }
>            }
>            catch (Exception ex)
>            {
>                Console.WriteLine(ex);
>                Console.WriteLine("Press any key to exit...");
>                Console.ReadKey();
>            }
>
>        }
> Can any one please suggest me what is missing in the above code?
> --
> View this message in context:
> http://www.nabble.com/Error-writing-to-broker.--Transport-connection-is-closed.-tp21348706p21348706.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>