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

Understanding how to connect to the public Fedora broker from outside using library #190

Closed
changlinli opened this issue Jun 22, 2019 · 6 comments

Comments

@changlinli
Copy link

Using fedora-messaging --conf=conf.toml consume --callback=fedora_messaging.example:printer I can successfully connect and see messages printing out.

Unfortunately when I run what I think is the equivalent code from the docs, I get nothing printed out to stdout at all (not even any connection information).

from fedora_messaging import api

# First, define a function to be used as our callback. This will be called
# whenever a message is received from the server.
def printer_callback(message):
    """
    Print the message to standard output.

    Args:
        message (fedora_messaging.message.Message): The message we received
            from the queue.
    """
    print(str(message))

# Next, we need a queue to consume messages from. We can define
# the queue and binding configurations in these dictionaries:
queues = {
    '00000000-0000-0000-0000-000000000000': {
        'durable': False,  # Delete the queue on broker restart
        'auto_delete': True,  # Delete the queue when the client terminates
        'exclusive': False,  # Allow multiple simultaneous consumers
        'arguments': {},
    },
}
binding = {
    'exchange': 'amq.topic',  # The AMQP exchange to bind our queue to
    'queue': '00000000-0000-0000-0000-000000000000',  # The unique name of our queue on the AMQP broker
    'routing_keys': ['#'],  # The topics that should be delivered to the queue
}

# Start consuming messages using our callback. This call will block until
# a KeyboardInterrupt is raised, or the process receives a SIGINT or SIGTERM
# signal.
api.consume(printer_callback, bindings=binding, queues=queues)

This is even if I set the FEDORA_MESSAGING_CONF environment variable to conf.toml. Is there some other configuration or logging that I'm missing?

@praiskup
Copy link

See #171 and #186. The example from docs doesn't work. Well I spent quite some time on trying to make this work (without success) ... and seems like I'm not alone.

I'd suggest at least to turn on the debugging output by default in the example, and while on it - consider adding a warning that it currently doesn't work.

@jeremycline
Copy link
Member

It would be good to add the log configuration setup to the snippet, yes.

@changlinli
Copy link
Author

@jeremycline After #192 I now get a clearer idea of what's wrong (this also saves me the effort of opening another ticket for trying to connect via Java's RabbitMQ library) so thanks a bunch!

I'm now seeing

[INFO fedora_messaging._session] Authenticating with server using x509 (certfile: fedora-cert.pem, keyfile: fedora-key.pem)
[INFO fedora_messaging._session] Connecting to rabbitmq.fedoraproject.org:5671
[INFO fedora_messaging._session] Successfully opened connection to rabbitmq.fedoraproject.org
[WARNING pika.channel] Received remote Channel.Close (403): "ACCESS_REFUSED - access to exchange 'amq.topic' in vhost '/public_pubsub' refused for user 'fedora'" on <Channel number=1 OPEN conn=<SelectConnection OPEN transport=<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x7f2872d1c588> params=<URLParameters host=rabbitmq.fedoraproject.org port=5671 virtual_host=/public_pubsub ssl=True>>>
[INFO fedora_messaging._session] Channel <Channel number=1 CLOSED conn=<SelectConnection OPEN transport=<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x7f2872d1c588> params=<URLParameters host=rabbitmq.fedoraproject.org port=5671 virtual_host=/public_pubsub ssl=True>>> closed (403): ACCESS_REFUSED - access to exchange 'amq.topic' in vhost '/public_pubsub' refused for user 'fedora'

and nothing else prints after that.

@jeremycline
Copy link
Member

@changlinli can you attach your configuration file. the code snippet you're running, and the commit you've got checked out? I did a test against the Fedora /public_pubsub vhost after the fix and it worked fine so I'll need to see your specific setup to reproduce it.

Thanks!

@changlinli
Copy link
Author

changlinli commented Jun 26, 2019

@jeremycline It looks like updating to the latest version of fedora-messaging did the trick! Thank you very much!

@changlinli
Copy link
Author

There's still a minor issue with the current docs that I've put in a small PR for here: #193

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

4 participants