<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>we ran into the same problem before. the workaround was to ignore SIGPIPE using:<br> signal(SIGPIPE, SIG_IGN);<br><br>from the man page for "write":<b><br>EPIPE</b><i><br>fd</i> is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive a <b>SIGPIPE</b> signal.
(Thus, the write return value is seen only if the program catches, blocks or ignores this signal.)<br><br>-alex<br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> David Wragg <david@rabbitmq.com><br><b><span style="font-weight: bold;">To:</span></b> underattack7 <underattack7@googlemail.com><br><b><span style="font-weight: bold;">Cc:</span></b> rabbitmq-discuss <rabbitmq-discuss@lists.rabbitmq.com><br><b><span style="font-weight: bold;">Sent:</span></b> Thu, February 10, 2011 9:11:38 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [rabbitmq-discuss] rabbitmq-c: how to catch a broken pipe with the rabbitmq server<br></font><br>
Hi,<br><br>underattack7 <<a ymailto="mailto:underattack7@googlemail.com" href="mailto:underattack7@googlemail.com">underattack7@googlemail.com</a>> writes:<br>> I am using the rabbitmq-c C libraries to publish messages to a Rabbitmq<br>> exchange.<br>><br>> Problem I have is that when rabbitmq server stops for some reason<br>> (rabbtmqctl stop_app / start_app for instance), the socket between my<br>> publisher program and rabbitmq is destroyed but I don't manage to catch any<br>> error code properly so that the program can try to establish a new<br>> connection.<br>><br>> When I stop rabbitmq, my publisher program exits with the message: "Broken<br>> Pipe" when it tries to send a message.<br><br>Sounds like a bug. What platform are you on?<br><br>> Is there a way to check the socket before sending a message so that I can<br>> try to re-establish a connection ?<br>><br>> The way I publish is
:<br>><br>> rc = amqp_basic_publish(amqp_connection, 1, amqp_cstring_bytes("Exchange"),<br>> amqp_cstring_bytes(routingkey), 0, 0, NULL, body);<br>><br>> if (rc < 0) {<br>> printf("error during publish : %s\n", strerror(-rc)) ;<br>> }<br><br>You should be using "amqp_error_string(-rc)" there, not strerror.<br><br>David<br><br>-- <br>David Wragg<br>Staff Engineer, RabbitMQ<br>SpringSource, a division of VMware<br>_______________________________________________<br>rabbitmq-discuss mailing list<br><a ymailto="mailto:rabbitmq-discuss@lists.rabbitmq.com" href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br></div></div>
</div><br>
</body></html>