Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Channel' object has no attribute 'basic' when publish message #57

Open
dizpers opened this issue Jun 5, 2014 · 5 comments

Comments

@dizpers
Copy link
Contributor

dizpers commented Jun 5, 2014

Hi! I write functional tests for my project, where I create RabbitMQ consumer using haigha =) There are both test producer and consumer in functional tests (started one by one). The producer randomly fails - opened channel closes randomly. When channel closed - no info is provided to close cb.

The only error I get is AttributeError: 'Channel' object has no attribute 'basic':

  File "/home/dizpers/work/myproject/.env/local/lib/python2.7/site-packages/haigha/channel.py", line 194, in publish
    self.basic.publish(*args, **kwargs)
AttributeError: 'Channel' object has no attribute 'basic'

What may cause this? How I can get more info from channel close callback? TIA!

PS The only cause I see for now is that consumer and producer started together.

@dizpers
Copy link
Contributor Author

dizpers commented Jun 6, 2014

It seems like that resetting rabbitmq helps me. RabbitMQ logs contained following:

=ERROR REPORT==== 6-Jun-2014::01:26:46 ===
connection <0.3637.0>, channel 1 - soft error:
{amqp_error,precondition_failed,
            "cannot redeclare exchange 'test_exchange' in vhost '/' with different type, durable, intern...",
            'exchange.declare'}

=WARNING REPORT==== 6-Jun-2014::01:26:46 ===
closing AMQP connection <0.3637.0> (127.0.0.1:34669 -> 127.0.0.1:5672):
connection_closed_abruptly

but the most interesting thing - that exchange declaration code doesn't changed during multiple test running =)

@awestendorf
Copy link
Member

Likely what happened is that the channel closed between when it was declared and when you attempted to publish, likely due to the protocol error you noted. Did you find a bug in your tests or is there a problem with exchange.declare?

@dizpers
Copy link
Contributor Author

dizpers commented Jul 10, 2014

I think exchange.declare is fine. I did't get this error since I rewrite my tests.

@simomo
Copy link

simomo commented Aug 12, 2014

Closing the channel ( channel.close() ) and then calling channel.basic may cause this error

@awestendorf
Copy link
Member

Yeah I just proposed in #61 a change to closed channels that would make it much clearer to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants