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'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"><<a href="mailto:alan.antonuk@gmail.com">alan.antonuk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I can'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"><<a href="mailto:mpietrek@skytap.com" target="_blank">mpietrek@skytap.com</a>></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'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 = "192.168.78.18" # 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__ == '__main__':</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="NotAValidQueue")</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 "channel.basic_get threw %s - This is expected" % (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 "channel.basic_get unexpectedly did not throw an exception."</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> print "Before channel.tx_select - Will hang on next line."</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 "After channel.tx_select - Unexpectedly got here."</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"><<a href="mailto:mpietrek@skytap.com" target="_blank">mpietrek@skytap.com</a>></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'm noticing some odd behavior, and am not sure if it's a problem on my end, on rabbitmq's end, or in Pika.</div>
<div><br></div><div>At it's simplest, I'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>'pika.exceptions.AMQPChannelError'>:(404, "NOT_FOUND - no queue 'foobar' in vhost '/'"</div>
<div><br></div><div>I'm baffled. Known issue? Something I'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>