Thanks for this info.<br><br>Fab<br><br><div class="gmail_quote">On 10 February 2011 20:02, alex chen <span dir="ltr">&lt;<a href="mailto:chen650@yahoo.com">chen650@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><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 &quot;write&quot;:<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 &lt;<a href="mailto:david@rabbitmq.com" target="_blank">david@rabbitmq.com</a>&gt;<br><b><span style="font-weight: bold;">To:</span></b> underattack7 &lt;<a href="mailto:underattack7@googlemail.com" target="_blank">underattack7@googlemail.com</a>&gt;<br>
<b><span style="font-weight: bold;">Cc:</span></b> rabbitmq-discuss &lt;<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a>&gt;<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><div><div></div><div class="h5"><br>
Hi,<br><br>underattack7 &lt;<a href="mailto:underattack7@googlemail.com" target="_blank">underattack7@googlemail.com</a>&gt; writes:<br>&gt; I am using the rabbitmq-c C libraries to publish messages to a Rabbitmq<br>&gt; exchange.<br>
&gt;<br>&gt; Problem I have is that when rabbitmq server stops for some reason<br>&gt; (rabbtmqctl stop_app / start_app for instance), the socket between my<br>&gt; publisher program and rabbitmq is destroyed but I don&#39;t manage to catch any<br>
&gt; error code properly so that the program can try to establish a new<br>&gt; connection.<br>&gt;<br>&gt; When I stop rabbitmq, my publisher program exits with the message: &quot;Broken<br>&gt; Pipe&quot; when it tries to send a message.<br>
<br>Sounds like a bug.� What platform are you on?<br><br>&gt; Is there a way to check the socket before sending a message so that I can<br>&gt; try to re-establish a connection ?<br>&gt;<br>&gt; The way I publish is
 :<br>&gt;<br>&gt; rc = amqp_basic_publish(amqp_connection, 1,� amqp_cstring_bytes(&quot;Exchange&quot;),<br>&gt; amqp_cstring_bytes(routingkey), 0, 0, NULL, body);<br>&gt;<br>&gt; if (rc &lt; 0)� {<br>&gt;� �  printf(&quot;error during publish : %s\n&quot;, strerror(-rc)) ;<br>
&gt;� }<br><br>You should be using &quot;amqp_error_string(-rc)&quot; there, not strerror.<br><br>David<br><br>-- <br>David Wragg<br>Staff Engineer, RabbitMQ<br>SpringSource, a division of VMware<br></div></div>_______________________________________________<br>
rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">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>

      </div></blockquote></div><br>