[rabbitmq-discuss] rabbitmq-c: how to catch a broken pipe with the rabbitmq server

David Wragg david at rabbitmq.com
Thu Feb 10 17:11:38 GMT 2011


Hi,

underattack7 <underattack7 at googlemail.com> writes:
> I am using the rabbitmq-c C libraries to publish messages to a Rabbitmq
> exchange.
>
> Problem I have is that when rabbitmq server stops for some reason
> (rabbtmqctl stop_app / start_app for instance), the socket between my
> publisher program and rabbitmq is destroyed but I don't manage to catch any
> error code properly so that the program can try to establish a new
> connection.
>
> When I stop rabbitmq, my publisher program exits with the message: "Broken
> Pipe" when it tries to send a message.

Sounds like a bug.  What platform are you on?

> Is there a way to check the socket before sending a message so that I can
> try to re-establish a connection ?
>
> The way I publish is :
>
> rc = amqp_basic_publish(amqp_connection, 1,  amqp_cstring_bytes("Exchange"),
> amqp_cstring_bytes(routingkey), 0, 0, NULL, body);
>
> if (rc < 0)  {
>     printf("error during publish : %s\n", strerror(-rc)) ;
>  }

You should be using "amqp_error_string(-rc)" there, not strerror.

David

-- 
David Wragg
Staff Engineer, RabbitMQ
SpringSource, a division of VMware


More information about the rabbitmq-discuss mailing list