[rabbitmq-discuss] Alternative Python AMQP client library
Barry Pederson
bp at barryp.org
Thu Jan 31 00:37:47 GMT 2008
kyles wrote:
> Hi Barry,
>
>
> Barry Pederson wrote:
>> I've seen a few Python users on this list, so I thought I'd mention that
>> I've been working on a Python AMQP client library as an alternative to
>> Qpid, and have a Mercurial repository and initial tarball available at:
>>
>> http://barryp.org/software/py-amqplib/
>>
>> The library is a bit rough, but I've been using it with RabbitMQ for a
>> while now.
>>
>
> I've been unable to get the amqplib client working when I'm running 2 or
> more nodes in a RabbitMQ cluster. Using a single node (local or remote)
> works fine. The error I'm getting is:
>
> Traceback (most recent call last):
> File "demo_send.py", line 56, in <module>
> main()
> File "demo_send.py", line 41, in main
> conn = amqp.Connection(options.host, userid=options.userid,
> password=options.password, ssl=options.ssl)
> File "/usr/local/lib/python2.5/site-packages/amqplib/client_0_8.py", line
> 180, in __init__
> self.close()
> File "/usr/local/lib/python2.5/site-packages/amqplib/client_0_8.py", line
> 420, in close
> (10, 61), # Connection.close_ok
> File "/usr/local/lib/python2.5/site-packages/amqplib/client_0_8.py", line
> 356, in wait
> frame_type, payload = self._wait_channel(0)
> File "/usr/local/lib/python2.5/site-packages/amqplib/client_0_8.py", line
> 298, in _wait_channel
> frame_type, frame_channel, payload = self._wait_frame()
> File "/usr/local/lib/python2.5/site-packages/amqplib/client_0_8.py", line
> 273, in _wait_frame
> frame_type = self.input.read_octet()
> File "/usr/local/lib/python2.5/site-packages/amqplib/util_0_8.py", line
> 96, in read_octet
> return unpack('B', self.input.read(1))[0]
> File "/usr/local/lib/python2.5/struct.py", line 87, in unpack
> return o.unpack(s)
> struct.error: unpack requires a string argument of length 1
> Exception socket.error: (32, 'Broken pipe') in <bound method
> Connection.__del__ of <amqplib.client_0_8.Connection object at 0xb7c7470c>>
> ignored
>
> Is this something you've seen before?
>
> Thanks,
> Kyle
Sorry, I haven't had a multi-node RabbitMQ setup to try anything like
that particular setup, so haven't seen that particular error.
It looks like the node you're connecting to is maybe trying to redirect
you to the other node, and then closing the socket without waiting for
the client to send a "close" message and then responding with "close-ok".
(Does the server initiate the exchange of "close"/"close-ok" messages
after a redirect? It wasn't clear to me from the specs.)
Anyhow, an easy workaround would be to wrap the call to self.close() in
line 180 of amqplib/client_0_8.py in a try/except block - so try
changing this:
--------
# we were redirected, close the socket, loop and try again
self.close()
--------
to this:
---------
# we were redirected, close the socket, loop and try again
try:
self.close()
except:
pass
---------
that might do the trick.
Barry
More information about the rabbitmq-discuss
mailing list