Azure / azure-uamqp-python

AMQP 1.0 client library for Python
MIT License
57 stars 46 forks source link

Appears to emit no valid protocol header? #44

Open grs opened 6 years ago

grs commented 6 years ago

I have been trying to run a simple example client against various different AMQP servers from the Apache Software Foundation (Apache ActivemMQ Artemis, Apache Qpid Dispatch Router and Apache c++ broker aka qpidd).

In all cases I am unable to connect. My test client is as follows:

import os
try:
    from urllib import urlparse
except ImportError:
    from urllib.parse import urlparse

import uamqp
from uamqp import authentication

uri = os.environ.get("AMQP_SERVICE_URI") or "amqp://localhost/foo"

def uamqp_receive_simple():
    parsed_uri = urlparse(uri)
    anon_auth = authentication.SASLAnonymous(parsed_uri.hostname, port=5672)

    message = uamqp.receive_message(uri, auth=anon_auth, debug=True)
    print("Received: {}".format(message))

if __name__ == "__main__":
    uamqp_receive_simple()

Viewing the interaction with wireshark, it appears that the client does not emit a valid AMQP protocol header at the start of the stream. I see 16 03 01 00 ab 01 00 00 seemingly every time as the first 8 bytes. The client then seems to spin in a loop, with cpu going to 100%.

If it is useful for testing, you can use:

docker run -it -p 5672:5672 docker.io/gordons/qdrouterd:1.3.0

To start an instance of qpid dispatch router listening on 5672 (no TLS, no auth required).

annatisch commented 6 years ago

Thanks @grs for these details!! I will try to repro :)

The only thing I can answer off the top of my head is the 100% CPU use - I generally assume that establishing the connection and authentication will a be quick process and therefore I made no effort to slow down iterating the connection as much as possible during this process.

Clearly this assumption is invalid in circumstances where:

So I will revisit the design there.

Again, thanks!

egandone commented 5 years ago

I've tripped across this issue as well when trying to use uAMQP against an ActiveMQ Artemis server.

If it helps I get an error in the artemis.log file on the broker:

AMQ224096: Error setting up connection from /localhost:53814 to /localhost:5672; protocol CORE not found in map: [AMQP]

For my test I tried using both plain and anonymous authentication. Both cause the same error on the broker and the client just hangs.

annatisch commented 5 years ago

Thanks for the report @egandone - I would really like to invest the time in getting this project working with these other AMQP servers - though unfortunately I wont be able to in the immediate future :(

I will hopefully be able to revisit this in the coming months as we are on-boarding more people to help with these projects.