Thanks Alan. After posting this, and doing some additional digging around, I also uncovered the AMQP spec portion that indicates an AMQPChannelError can result in a closed channel.<br><br>FWIW, I subsequently tried to detect this condition and reestablish the channel before subsequent uses. However, I ran into problems with Pika 0.9.5, wherein the old channels hung around. Subsequent digging turned up that there was a bug in Pika 0.9.5 where the correct response isn&#39;t set back to the server in this situation.<br>
<br>Switching to 0.9.6pre, I got further (at least I could close the old channel without hanging.) However, there was still enough issues that I backed off to a more brute force solution - If the channel receives an exception, I simply kill the connection and reestablish a new connection and channel. Probably not optimal, but it seems more reliable.<br>
<br>Matt<br><br><br><div class="gmail_quote">On Wed, Mar 28, 2012 at 11:14 AM, Alan Antonuk <span dir="ltr">&lt;<a href="mailto:alan.antonuk@gmail.com">alan.antonuk@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I can&#39;t tell you why its hanging, but in general when a channel throws an exception, the channel is closed (its how the AMQP protocol works). �Trying to use the channel after a channel exception (or any closed channel) will result in connection exception which will shut down the entire connection.<div>

<br></div><div>-Alan<br><br><div class="gmail_quote"><div><div class="h5">On Wed, Mar 28, 2012 at 2:04 PM, Matt Pietrek <span dir="ltr">&lt;<a href="mailto:mpietrek@skytap.com" target="_blank">mpietrek@skytap.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Following up on this problem, I&#39;ve narrowed the issue down to a trivial example that hangs:<br><br><span style="font-family:courier new,monospace">import pika</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">HOSTNAME = &quot;192.168.78.18&quot;� # Plug in your own server name here.</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">if __name__ == &#39;__main__&#39;:</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� connection = pika.BlockingConnection(pika.ConnectionParameters(host=HOSTNAME, port=5672))</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��� channel = connection.channel()</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� try:</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������� method_frame, _, body = channel.basic_get(queue=&quot;NotAValidQueue&quot;)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� except Exception as e:</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������� print &quot;channel.basic_get threw %s - This is expected&quot; % (e)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� else:</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������� print &quot;channel.basic_get unexpectedly did not throw an exception.&quot;</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��� print &quot;Before channel.tx_select - Will hang on next line.&quot;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� channel.tx_select()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��� print &quot;After channel.tx_select - Unexpectedly got here.&quot;</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��� channel.tx_commit()</span><div>

<div><br>
<br><br><div class="gmail_quote">On Tue, Mar 27, 2012 at 4:54 PM, Matt Pietrek <span dir="ltr">&lt;<a href="mailto:mpietrek@skytap.com" target="_blank">mpietrek@skytap.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word"><div>I have a Pika 0.9.5. app communicating with a 2.81 rabbitmq-server instance.</div><div><br></div><div>I&#39;m noticing some odd behavior, and am not sure if it&#39;s a problem on my end, on rabbitmq&#39;s end, or in Pika.</div>


<div><br></div><div>At it&#39;s simplest, I&#39;m seeing a call to channel.tx_select() hang. Breaking in with the debugger, the stack looks like this:</div><div><br></div><div><div>_handle_read [base_connection.py:151]<span style="white-space:pre-wrap">        </span></div>


<div>process_data_events [blocking_connection.py:94]<span style="white-space:pre-wrap">        </span></div><div>send_method [blocking_connection.py:244]<span style="white-space:pre-wrap">        </span></div><div>rpc [blocking_connection.py:216]<span style="white-space:pre-wrap">        </span></div>


<div>tx_select [spec.py:2615]<span style="white-space:pre-wrap">        </span></div></div><div><br></div><div>Stepping for a bit, I see that the code never gets out of the loop in the send_method() function.</div><div><br></div>


<div>In ordinary circumstances, my code that calls tx_select() works fine. However, in the case where it hangs, an immediately prior call to channel.basic_get() has thrown an exception:</div><div><br></div><div>&#39;pika.exceptions.AMQPChannelError&#39;&gt;:(404, &quot;NOT_FOUND - no queue &#39;foobar&#39; in vhost &#39;/&#39;&quot;</div>


<div><br></div><div>I&#39;m baffled. Known issue? Something I&#39;m doing wrong?</div><div><br></div><div>Thanks,</div><div><br></div><div>Matt</div></div>
</blockquote></div><br>
</div></div><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>
<br></blockquote></div><br></div>
</blockquote></div><br>