gmr / rabbitpy

A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
http://rabbitpy.readthedocs.org
BSD 3-Clause "New" or "Revised" License
242 stars 58 forks source link

Publishing not working #107

Closed tarhann closed 5 years ago

tarhann commented 7 years ago

Hey,

I got Python 3.5.2 here, on a ubuntu 16.04 and a rabbitpy of version 1.0.0. When executing exactly the code from the example in "Mandatory Publishing" http://rabbitpy.readthedocs.io/en/latest/examples/publisher_confirms.html I got that error:

$ python3 publish_example.py

Traceback (most recent call last):
  File "publish_example.py", line 19, in <module>
    print('RabbitMQ indicates message publishing failure')
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/connection.py", line 149, in __exit__
    raise exc_val
  File "publish_example.py", line 19, in <module>
    print('RabbitMQ indicates message publishing failure')
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/channel.py", line 99, in __exit__
    raise exc_val
  File "publish_example.py", line 16, in <module>
    if message.publish('test_exchange', 'test-routing-key', mandatory=True):
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/message.py", line 288, in publish
    response = self.channel.wait_for_confirmation()
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/base.py", line 242, in wait_for_confirmation
    specification.Basic.Nack])
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/base.py", line 464, in _wait_on_frame
    self._check_for_rpc_request(value)
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/channel.py", line 271, in _check_for_rpc_request
    super(Channel, self)._check_for_rpc_request(value)
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/base.py", line 328, in _check_for_rpc_request
    self._on_remote_close(value)
  File "/usr/local/lib/python3.5/dist-packages/rabbitpy/base.py", line 380, in _on_remote_close
    raise exceptions.AMQP[value.reply_code](value)
rabbitpy.exceptions.AMQPNotFound: <pamqp.specification.Channel.Close object at 0x7ffa2f81a5a0>

I tried this example, because in the app I am building, publishing also doesn't work. As you can see, the broker is up and running, also the connection gets established nicely. But when it comes to find the proper exchange, a 404 is returned. I tried another URL without the trailing / for the vhost, resp. omitted the exchange, but neither worked out.

/usr/local/lib/python3.5/dist-packages/rabbitpy/base.py:380: AMQPNotFound
---------------------------------------------- Captured log -----------------------------------------------
base.py                    100 DEBUG    Connection setting state to 'Opening'
base.py                    100 DEBUG    IO setting state to 'Opening'
events.py                  132 DEBUG    Waiting for 3 seconds on event: Socket Connected
io.py                      532 DEBUG    Connecting to ('172.18.0.2', 5672)
base.py                    100 DEBUG    IO setting state to 'Open'
io.py                      400 DEBUG    Socket connected
connection.py              246 DEBUG    Adding channel 0 to io
base.py                    100 DEBUG    Channel0 setting state to 'Opening'
io.py                      235 DEBUG    Returning PollPoller
channel0.py                101 DEBUG    Received frame: 'Connection.Start'
channel0.py                242 DEBUG    Server b'version': b'3.6.5'
channel0.py                242 DEBUG    Server b'cluster_name': b'rabbit@a2930e58b427'
channel0.py                242 DEBUG    Server b'platform': b'Erlang/OTP'
channel0.py                242 DEBUG    Server b'capabilities': {b'per_consumer_qos': True, b'authentication_failure_close': True, b'consumer_cancel_notify': True, b'publisher_confirms': True, b'basic.nack': True, b'connection.blocked': True, b'direct_reply_to': True, b'consumer_priorities': True, b'exchange_exchange_bindings': True}
channel0.py                242 DEBUG    Server b'product': b'RabbitMQ'
channel0.py                242 DEBUG    Server b'copyright': b'Copyright (C) 2007-2016 Pivotal Software, Inc.'
channel0.py                242 DEBUG    Server b'information': b'Licensed under the MPL.  See http://www.rabbitmq.com/'
channel0.py                101 DEBUG    Received frame: 'Connection.Tune'
channel0.py                259 DEBUG    Heartbeat interval (server/client): 60/60
channel0.py                101 DEBUG    Received frame: 'Connection.OpenOk'
channel0.py                219 DEBUG    Connection opened
base.py                    100 DEBUG    Channel0 setting state to 'Open'
heartbeat.py                36 DEBUG    Heartbeat started, ensuring data is written at least every 30.00 seconds
base.py                    100 DEBUG    Connection setting state to 'Open'
endpoint.py                100 INFO     Established connection to host: rabbitmq, port: 5672
connection.py              246 DEBUG    Adding channel 1 to io
base.py                    100 DEBUG    Channel setting state to 'Opening'
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Channel.OpenOk object at 0x7f815dd24c48>
base.py                    100 DEBUG    Channel setting state to 'Open'
channel.py                 186 DEBUG    Channel #1 open
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Confirm.SelectOk object at 0x7f815dcabb70>
endpoint.py                111 INFO     Created channel
amqp_queue.py              384 DEBUG    Declaring Queue test_queue, durable=False, passive=False, exclusive=False, auto_delete=False, arguments={}
base.py                     37 DEBUG    Issuing RPC to RabbitMQ: <pamqp.specification.Queue.Declare object at 0x7f815dc86e18>
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Queue.DeclareOk object at 0x7f815dcb2b88>
endpoint.py                139 INFO     Declared queue with name: test_queue
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Basic.ConsumeOk object at 0x7f815dd24cd8>
base.py                    100 DEBUG    Connection setting state to 'Opening'
base.py                    100 DEBUG    IO setting state to 'Opening'
events.py                  132 DEBUG    Waiting for 3 seconds on event: Socket Connected
io.py                      532 DEBUG    Connecting to ('172.18.0.2', 5672)
base.py                    100 DEBUG    IO setting state to 'Open'
io.py                      400 DEBUG    Socket connected
io.py                      235 DEBUG    Returning PollPoller
connection.py              246 DEBUG    Adding channel 0 to io
base.py                    100 DEBUG    Channel0 setting state to 'Opening'
channel0.py                101 DEBUG    Received frame: 'Connection.Start'
channel0.py                242 DEBUG    Server b'version': b'3.6.5'
channel0.py                242 DEBUG    Server b'cluster_name': b'rabbit@a2930e58b427'
channel0.py                242 DEBUG    Server b'platform': b'Erlang/OTP'
channel0.py                242 DEBUG    Server b'capabilities': {b'per_consumer_qos': True, b'authentication_failure_close': True, b'consumer_cancel_notify': True, b'publisher_confirms': True, b'basic.nack': True, b'connection.blocked': True, b'direct_reply_to': True, b'consumer_priorities': True, b'exchange_exchange_bindings': True}
channel0.py                242 DEBUG    Server b'product': b'RabbitMQ'
channel0.py                242 DEBUG    Server b'copyright': b'Copyright (C) 2007-2016 Pivotal Software, Inc.'
channel0.py                242 DEBUG    Server b'information': b'Licensed under the MPL.  See http://www.rabbitmq.com/'
channel0.py                101 DEBUG    Received frame: 'Connection.Tune'
channel0.py                259 DEBUG    Heartbeat interval (server/client): 60/60
channel0.py                101 DEBUG    Received frame: 'Connection.OpenOk'
channel0.py                219 DEBUG    Connection opened
base.py                    100 DEBUG    Channel0 setting state to 'Open'
heartbeat.py                36 DEBUG    Heartbeat started, ensuring data is written at least every 30.00 seconds
base.py                    100 DEBUG    Connection setting state to 'Open'
endpoint.py                100 INFO     Established connection to host: rabbitmq, port: 5672
connection.py              246 DEBUG    Adding channel 1 to io
base.py                    100 DEBUG    Channel setting state to 'Opening'
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Channel.OpenOk object at 0x7f815dd24f18>
base.py                    100 DEBUG    Channel setting state to 'Open'
channel.py                 186 DEBUG    Channel #1 open
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Confirm.SelectOk object at 0x7f815dcabba8>
endpoint.py                111 INFO     Created channel
channel.py                 270 DEBUG    Checking for RPC request: <pamqp.specification.Channel.Close object at 0x7f815c608f30>
base.py                    327 DEBUG    Channel closed
base.py                    100 DEBUG    Channel setting state to 'Remotely Closed'
base.py                    379 ERROR    Received remote close (404): b"NOT_FOUND - no exchange 'test-exchange' in vhost '/'"

This is how I open a connection:

        self._connection = rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2F')

After that the channels/ connection are closed. I am sure, I am missing something and really could use a nudge in the right direction.

Thanks in advance :-)

novalis111 commented 6 years ago

This comes a bit late, but the error states that the defined exchange is unknown. Unfortunately this reply does not bubble up and rabbitpy quits with this (not helpful) AMQPNotFound Exception.

gmr commented 6 years ago

nod that is the exception as defined in the protocol and any correlation would be haphazard at best to figure out why RabbitMQ is returning that, given how the protocol works.

gmr commented 5 years ago

Going to close this, but the AMQP NotFoundException is straight out of the protocol and the response from RabbitMQ. I guess I could create a bunch of new exceptions inspecting the not found exception for what was not found, but that seems like a fair amount of extra code with little value.