[rabbitmq-discuss] rabbitmq-c: how to catch a broken pipe with the rabbitmq server
alex chen
chen650 at yahoo.com
Thu Feb 10 20:02:13 GMT 2011
we ran into the same problem before. the workaround was to ignore SIGPIPE
using:
signal(SIGPIPE, SIG_IGN);
from the man page for "write":
EPIPE
fd is connected to a pipe or socket whose reading end is closed. When this
happens the writing process will also receive a SIGPIPE signal. (Thus, the write
return value is seen only if the program catches, blocks or ignores this
signal.)
-alex
________________________________
From: David Wragg <david at rabbitmq.com>
To: underattack7 <underattack7 at googlemail.com>
Cc: rabbitmq-discuss <rabbitmq-discuss at lists.rabbitmq.com>
Sent: Thu, February 10, 2011 9:11:38 AM
Subject: Re: [rabbitmq-discuss] rabbitmq-c: how to catch a broken pipe with the
rabbitmq server
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
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110210/4919f2ef/attachment-0001.htm>
More information about the rabbitmq-discuss
mailing list