Erlang Mailing Lists

Author Message

<  RabbitMQ mailing list  ~  Alternative Python AMQP client library

Guest
Posted: Wed Jan 30, 2008 9:40 pm Reply with quote
Guest
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
--
View this message in context: http://www.nabble.com/Alternative-Python-AMQP-client-library-tp14139740p15192757.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
Guest
Posted: Thu Jan 31, 2008 12:38 am Reply with quote
Guest
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



_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
Guest
Posted: Fri Feb 01, 2008 11:39 pm Reply with quote
Guest
Barry Pederson wrote:
> kyles wrote:
>>
>> 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".
>
Yes, I get the same very exception when broker replies with a redirect.

You can also use insist flag when starting a connection:

client = Connection(host=myip, userid='guest', password='guest', insist=True)

This should work with the latest version of amqplib.

In my tests I have never seen a broker respond with redirect when I set insist to True,
even though according to the spec, a broker SHOULD accept a connection (not MUST):

<field name="insist" type="bit">
insist on connecting to server
<doc>
In a configuration with multiple load-sharing servers, the server
may respond to a Connection.Open method with a Connection.Redirect.
The insist option tells the server that the client is insisting on
a connection to the specified server.
</doc>
<rule implement="SHOULD">
When the client uses the insist option, the server SHOULD accept
the client connection unless it is technically unable to do so.
</rule>
</field>


- Dmitriy




_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum