GOAL: Receive messages from EventHub with python.
Setup:
- Python 3.5
- AMQP 1.0
- EventHub created in new portal.
- Ubuntu 16.04 and Mac OS X.
- proton==0.8.8 and python-qpid-proton==0.17.0
I have been trying to get a connection with AMQP to Azure EventHub for a couple days now. I can do this fine with the Java Client (as a test to make sure the EventHub was working) but I need to be able to do this with Python.
After reading a couple examples online I have tried a lot of things over the past days.
I am using the RootManageSharedAccessKey
and the generated key which doesn't have any /
for me. I have tried urllib.quote
as well as normal.
Currently my string looks like:
amqps://RootManageSharedAccessKey:<primary key>@<namespace>.servicebus.windows.net/<internal hub name>
If I copy these same parameters into the Java client it works fine. If I use the python SDK to send it works fine as well (it sends it over HTTPS). I have tried using amqps
and amqp
if I turn on the debug parameter for AMQP I get the error:
condition=:"amqp:unauthorized-access",
description="Unauthorized access. 'Send' claim(s) are required to perform this operation.
Resource: 'sb://<namespace>.servicebus.windows.net/<internal event hub>
That sounds to be a permission issue but the same keys and everything work perfect in Java and in Python over HTTPS so it has to be something in my code vs the keys. Maybe I am not encoding them correctly (I have read you don't need to encode them)? Once I get it working I'll make a GIST and an update for anyone else.
My Current Code is as follows for send which should be easier:
from proton import Messenger, Message
messenger = Messenger()
message = Message()
key = "key"
message.address = "amqps://RootManageSharedAccessKey:"+key+"@<namespace>.servicebus.windows.net/<hubname>"
message.body = u"This is a text string"
messenger.put(message)
messenger.send()`
Things I have tried:
- Making policies for both send and receive separate on both the event hub and the namespace.
- Recreating the hub
- Secure vs Unsecure
- Adding the ports to the Firewall
- Python 2.7 proton vs 3.5
- Linux vs Mac
- Primary key vs Secondary key
- New namespaces
- New Keys with and without
/
in the key - URL encoding portions and the whole string
- UTF-8 encoding
- JSON messages vs text messages.
PN_TRACE_FRM=true;
and it outputs the logs. of what is happening. I did not build proton from source maybe I should try that. Do you have a redacted gist of how your got yours working you would be willing to share? – JimYong